How do I time something in a OnPlayerCommandText? -
Prostilov - 26.04.2012
I am trying to make a /helpup system where a player would be down on the ground and another player can /helpup them.
The player being wounded on the ground works and stuff but, I want it to take 10 seconds before a player can get back up. (the help up process requires 10 seconds to be succesful.)
However, if I use a timer to call a function, it won't recognize the ID of the player being helped value anymore, neither will it recognize the name of the player being helped or their health.
Код:
if (strcmp(cmd, "/helpup", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new playerName[MAX_PLAYER_NAME];
new helpPlayerName[MAX_PLAYER_NAME];
new Float:hPlayerHealth;
new Float:playerHealth;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /helpup [PlayerID/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
GetPlayerName(playerid, playerName, sizeof(playerName));
GetPlayerName(giveplayerid, helpPlayerName, sizeof(helpPlayerName));
GetPlayerHealth(giveplayerid, hPlayerHealth);
GetPlayerHealth(playerid, playerHealth);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(GetDistanceBetweenPlayers(playerid,giveplayerid) < 3)
{
if(hPlayerHealth <= 35.0 && playerHealth > 35.0)
{
ApplyAnimation(playerid, "MEDIC", "CPR", 4.0, 1, 0, 0, 1, 0, 1);
SetTimer("timeGetUpPlayer", 10000, false);
format(string, sizeof(string), "%s is helping %s getting up.", playerName, helpPlayerName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
format(string, sizeof(string), "~w~Helping ~r~%s~w~ up", helpPlayerName);
GameTextForPlayer(playerid, string, 10000, 1);
format(string, sizeof(string), "~w~You are being helped up");
GameTextForPlayer(giveplayerid, string, 10000, 1);
}
else if(playerHealth <= 35.0)
{
SendClientMessage(playerid, COLOR_RED, "You can't help someone up when you are lying on the ground yourself!");
}
else if(hPlayerHealth > 35.0)
{
SendClientMessage(playerid, COLOR_GREY, "That player is still able to walk.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not near that player!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "That player doesn't exist or is currently not on the server!");
}
}
}
return 1;
}
Is there anyway where I can make it so the player being helped can stand up again, after 10 seconds or make a function remember the values?
Re: How do I time something in a OnPlayerCommandText? -
Prostilov - 26.04.2012
It's really really urgent, I need help.
Re: How do I time something in a OnPlayerCommandText? -
Vince - 26.04.2012
Use SetTimerEx and pass the playerd.
Re: How do I time something in a OnPlayerCommandText? -
Prostilov - 26.04.2012
Could you show me how to? (I'm not really that advanced in pawn, I've started scripting long time ago and I'm trying to remember everything.)
PS: I live in Belgium too.