/Donut -
G*Mafia - 08.03.2011
Hello, I've made a /donut command that it will refills your health, but i want it to refill my health slowly, like refills 2 precent of my health each secend, not sets my health 100 in one sec (SetPlayerHeath) anyone knows how please tell me
Re: /Donut -
xRyder - 08.03.2011
Use SetTimerEx() function.
Re: /Donut -
antonio112 - 08.03.2011
Quote:
Originally Posted by xRyder
Use SetTimerEx() function.
|
Yea, I tought about that aswell but what can you do to stop it, when his HP reaches 100% ? I mean like, I`m pretty sure he doesn`t want to continusly heal him, till he /q's
Re: /Donut -
Calgon - 08.03.2011
Put this in your command:
pawn Код:
// Set a repeating timer to call function 'donutHealth' every second.
SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
and out of your command:
pawn Код:
// Forward our function
forward donutHealth(playerid);
// Create our function
public donutHealth(playerid) {
// Create a temp. variable to store the player's health
new
Float: fHealth;
// Get the player's health
GetPlayerHealth(playerid, fHealth);
// Check if the player has MORE than 100 health.
if(fHealth > 100) {
return KillTimer(GetPVarInt(playerid, "donutHealth")); // Cancel the timer/function and don't add health
}
// Add health if everything is okay!
SetPlayerHealth(playerid, fHealth+5);
return 1;
}
Untested.
Re: /Donut -
Steven82 - 08.03.2011
Quote:
Originally Posted by antonio112
Yea, I tought about that aswell but what can you do to stop it, when his HP reaches 100% ? I mean like, I`m pretty sure he doesn`t want to continusly heal him, till he /q's
|
Thats why there is a function called "KillTimer" dumb---..i mean really, just check the wiki next time about the timer functions then reply.
Re: /Donut -
G*Mafia - 09.03.2011
I added this in my pawno
pawn Код:
dcmd_donut(playerid,params[])
// Set a repeating timer to call function 'donutHealth' every second.
SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
// Forward our function
forward donutHealth(playerid);
// Create our function
public donutHealth(playerid) {
// Create a temp. variable to store the player's health
new
Float: fHealth;
// Get the player's health
GetPlayerHealth(playerid, fHealth);
// Check if the player has MORE than 100 health.
if(fHealth > 100) {
return KillTimer(GetPVarInt(playerid, "donutHealth")); // Cancel the timer/function and don't add health
}
// Add health if everything is okay!
SetPlayerHealth(playerid, fHealth+5);
return 1;
}
But it didint work in game, It said unknown command, Help please.
Re: /Donut -
boelie - 09.03.2011
show us the command
Re: /Donut -
HyperZ - 09.03.2011
Quote:
Originally Posted by G*Mafia
I added this in my pawno
pawn Код:
dcmd_donut(playerid,params[]) // Set a repeating timer to call function 'donutHealth' every second. SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
// Forward our function forward donutHealth(playerid);
// Create our function public donutHealth(playerid) { // Create a temp. variable to store the player's health new Float: fHealth;
// Get the player's health GetPlayerHealth(playerid, fHealth);
// Check if the player has MORE than 100 health. if(fHealth > 100) { return KillTimer(GetPVarInt(playerid, "donutHealth")); // Cancel the timer/function and don't add health } // Add health if everything is okay! SetPlayerHealth(playerid, fHealth+5); return 1; }
But it didint work in game, It said unknown command, Help please.
|
pawn Код:
dcmd_donut(playerid,params[])
{
SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
return 1;
}
forward donutHealth(playerid);
public donutHealth(playerid)
{
new Float: fHealth;
GetPlayerHealth(playerid, fHealth);
if(fHealth > 100)
return KillTimer(GetPVarInt(playerid, "donutHealth"));
SetPlayerHealth(playerid, fHealth+5);
return 1;
}
Re: /Donut -
Sasino97 - 09.03.2011
Quote:
Originally Posted by G*Mafia
I added this in my pawno
pawn Код:
dcmd_donut(playerid,params[]) // Set a repeating timer to call function 'donutHealth' every second. SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
// Forward our function forward donutHealth(playerid);
// Create our function public donutHealth(playerid) { // Create a temp. variable to store the player's health new Float: fHealth;
// Get the player's health GetPlayerHealth(playerid, fHealth);
// Check if the player has MORE than 100 health. if(fHealth > 100) { return KillTimer(GetPVarInt(playerid, "donutHealth")); // Cancel the timer/function and don't add health } // Add health if everything is okay! SetPlayerHealth(playerid, fHealth+5); return 1; }
But it didint work in game, It said unknown command, Help please.
|
Brackets.... blabla(playerid, params)
{
Re: /Donut -
Mean - 09.03.2011
Brackets are not needed here, nor they will not change anything, isn't it logic that you can use it like this:
pawn Код:
dcmd_something( playerid, params[ ] )
return SendClientMessage( playerid, 0xAAAAAA, "abcd" );
If you can use this, you can also use:
pawn Код:
dcmd_donut(playerid,params[])
SetPVarInt(playerid, "donutHealth", SetTimerEx("donutHealth", 1000, true, "i", playerid));
So, probbably, not a bracket problem.
The real problem was you need to use return.
pawn Код:
dcmd_donut(playerid,params[])
SetPVarInt(playerid, "donutHealth"); return SetTimerEx("donutHealth", 1000, true, "i", playerid);