Does anybody know how to make it so my character can have health, and when he gets hit he loses some? I want your 'health' to always be on the screen also, but I don't know how to do that ethier. Any ideas?
Basicly, just use a variable for the health... for example a globalint, say number 100 in this case. In the game_start global function, set the globalint to the health amount you want the character to have, and use the SetGlobalInt(INT, VALUE); to change the health. Like SetGlobalInt(100, -10); would decrease the player's health with 10.
To display it on the screen, create a GUI and a label on it. Set the label text to for example "Health: 100" and in the repeadetly_execute global function put:
StrFormat(hlthstr, "Heath:%d", GetGlobalInt(100));
SetLabelText(GUI, LABEL, hlthstr);
and in the beginning of the global script:
string hlthstr;
would make it display the health on the GUI you made. Just replace the GUI with the GUI name and LABEL with the label number.
using Setglobalint (100,-10); will turn the int(100) to -10 value, not 90.
I used that option:
if (GetGlobalInt(100)==10) SetGlobalInt(100,0);
if (GetGlobalInt(100)==20) SetGlobalInt(100,10);
if (GetGlobalInt(100)==30) SetGlobalInt(100,20);
if (GetGlobalInt(100)==40) SetGlobalInt(100,30);
if (GetGlobalInt(100)==50) SetGlobalInt(100,40);
if (GetGlobalInt(100)==60) SetGlobalInt(100,50);
if (GetGlobalInt(100)==70) SetGlobalInt(100,60);
if (GetGlobalInt(100)==80) SetGlobalInt(100,70);
if (GetGlobalInt(100)==90) SetGlobalInt(100,80);
if (GetGlobalInt(100)==100) SetGlobalInt(100,90);
but if the Health goes by -1 ~ -9 points dont work unless use one IF for each Health point.
Oops...
It goes this way:
SetGlobalInt(100, GetGlobalInt(100) - 10);
oh. Nice. better than 100 if lines ;D
thankx Tk u helped me too
Hey, Thanks a lot you guys, you all helped me out big time!! 8)
Wait, It displays it and all, but for the actuall health it just displays a 0??(zero)
have u put in the beggining of the global script setglobalint(100,100); ?
I tried that, but I just get an error saying:
---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was in 'Main script':
Error (line 2): Parse error: unexpected 'SetGlobalInt'
Do you want to fix the script now? (Your game has not been saved).
---------------------------
Yes No
---------------------------
whoops, lol! EXTREMELY STUPID error from me...I put it above The function game_start() command... ;D