![]() |
Food Bar
I'm trying to make a food system for Dark Rival. So far, i can make the person need food, and their hunger grow, etc, but i can't make it display a 'food bar, under the MP bar, that would slowly decrease. Anyone know how i would do it?
|
showimg, changeimgvis, changeimgpart
|
yeah, but that puts the image at a specific x and y, on the level
|
changeimgvis.
|
=/ still having trouble, but this is a start X_x
that puts it in the top corner, it moves, but it is above the asd thing X_X how your i move it down |
When you are working on the level layers, image X and Ys reference to coordinates on the level.
When you are working on the GUI layers, image X and Ys reference to the actual position on the screen (pixel coordinates, that is), starting from the top-left corner of the Graal window. |
If you want to display the bar on the right side of the screen, do screenwidth-whatever for displaying. This ensures that people who resize their screen will still have the same format.
|
im having trouble making the food points part of the bar to go down, changeimgpart in't working, but then again, im not sure i did it right. any suggestions on how to make the bar shrink by 1 each time it runs through the loop?
|
changeimgpart not changeimgparts
|
sorry...typo X_x
i do mean changeimgpart and nope, still cant get it. i have the bar up and lined up, the Fp runs out etc, but i cant get the bar to shrink as the food points run out. X_x |
Can you post your changeimgpart line?
|
It could be a stupid mistake, such as forgetting to put the bar drawing in a repeating timeout :\. Also, a little thing in there is that if you tell it to draw the image width as 0, it will draw the entire thing. There's my two cents, but the code would be nice, yes.
|
You don't need to keep updating the HP in a timeout. You can add a simple validation to check if the HP is changed from before.
|
There are multiple ways to do it. You could have the food value have a max of 100 and a min of 1. Then you just do something like:
changeimgpart index,0,0,foodvalue,10; Which would make the food bar display from an x of 0 to an x of whatever your food value is... like if it were 50, it would display from 0 to 50, which would be half the bar, if your bar was 100 pixels in width. Otherwise you're going to need a small formula to adjust for the difference in pixel width to food value. |
this is what I have so far, I might make it set your hearts to 1 or .5 if it tuns out, instead of killing you, that way you have time to get food:
// NPC made by Excaliber //this script makes the player say their food points. It usually would not take 1 sec to lose a point, but this was for testing, this is for offline mode right now, with toweapons I will need one for online mode if(playerenters){client.food=100;} //#CLIENTSIDE if(playerenters){ client.food=100; toweapons *Food System;} while(isweapon){ setplayerprop #c,#v(client.food); client.food=client.food-1; changeimgpart 1,0,0,client.food,10; if(client.food<1){ playerhearts=0;client.food=1} sleep 1} if(created){ showimg 2,drfoodbarback.png,15,115; changeimgvis 2,4; showimg 1,drfoodbarfp.png,37,121; changeimgvis 1,4;} if(playerchats&&strequals(#c,/food)){ setplayerprop #c,#v(client.food)} |
maybe u should use code tags
NPC Code: hmm i think u should use setstring instead of client.food=; then use probably want to use a timeout... didnt test it cuz i dont have the images and i used the imgwidth and imageheight cuz i dont know how width/height your images are |
Quote:
|
It's probably better if you used clientr. strings, unless you don't care about people cheating your system and using a memory editor to make it so their hunger meter never goes down.
|
Quote:
|
clietntr?
i used them once for a weapons saver, but i wasn't 100% what they were for X_x btw, i got it to work, yours wasn't perfect, but i couldnt do it w/o it thanks! :D |
Quote:
client. strings are readable and writable both on the clientside and the serverside. |
it works fine off line, but i'm having trouble online here is the current script i'm using:
NPC Code://#CLIENTSIDE |
Quote:
|
it wasn't toweapons, but i got it fixed :D
but now im having more problems w/ the food. i have putnpc enabled, but for some reason, it's not puiing in npc, what could be wrong? |
Paste the putnpc2 script? lol.
|
i wasn't aware there was a putnpc2 command =/
whats the format of it? |
putnpc2 x,y,{script};
|
Quote:
|
Quote:
|
yeah i've noticed...tons of lag X_x
|
Quote:
NPC Code: |
when it's loading it lags alot, and with multiple players in the level, or many NPCs, you could have trouble. X_x
|
That's why you put things in an event block and NOT outside.
You can use while, just make sure it isn't an infinite loop. |
Quote:
Anyway. Using while serverside to run as many loops as it possibly can (not just 10 in your case) will likely cause problems on a server. |
Infinite loops serverside have crashed servers. I've personally watched someone do this on Doomsday z-z and I accidentally did it myself on Babylon. You want the serverside script to run /once/, and that's only when changing clientr strings or adding/removing weapons, etc. You shouldn't use showimg or any image commands serverside, unless you have to, due to the lack of a triggeraction to clientside in level npcs z-z HINT HINT STEFAN!
Infinite loops = bad Infinite loops serverside = very bad |
Quote:
|
Quote:
|
Quote:
Calani: showtext() does not work serverside. Showimg() and Showimg(@@@) DO work serverside. |
o.o kay.
waiiiit, how aobut serverside in levelnpcs? (such as from joined classes) |
Quote:
Quote:
EDIT Eep, didn't clarify. Information gathered from/by (I use those two words interchangeably, they mean the same thing to me z-z) and used by the same or another level or DB npc. |
| All times are GMT +2. The time now is 09:25 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.