Last Player Function!
#1

Hey guys! i'm thinking if is it possible to make Last Player Function??

Example:
/heal roberto
SendMessage: You can't heal roberto 2 times in row, please choose another player.
Reply
#2

use player variable like
new LastPlayerHeal[MAX_PLAYERS];
Reply
#3

pawn Код:
new TotalHeal[MAX_PLAYERS];

CMD:heal(playerid, params[])
{
// your code
TotalHeal[playerid]++;
}
And make command or whatever that reset TotalHeal if you want to.
Reply
#4

no not that what i want
Reply
#5

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
no not that what i want
So, what do you want, explain it detaily, so we can help you.
Reply
#6

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
So, what do you want, explain it detaily, so we can help you.
He wants to get the last command used so they can't use it twice.
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
He wants to get the last command used so they can't use it twice.
not that too
this is a SetTimerEx

all i want is:

/heal SickAttack
SendMessage: You can't heal SickAttack 2 times in row, please heal another player then get back to him.

this will stop the heal spamming for the same targetid.
Reply
#8

Then just store the player's ID you just healed and then check if the player ID you want to heal now is the same as before, like this:
Код:
new LastPlayerHealed[MAX_PLAYERS];

//in command:
if(LastPlayerHealed[playerid] == targetid) //or something other than targetid for the target^^ depends on your command code
{
	return SendClientMessage(playerid, -1, "You can't heal this player twice. Please heal another player first!");
}
LastPlayerHealed[playerid] = targetid;
Reply
#9

Quote:
Originally Posted by Macronix
Посмотреть сообщение
Then just store the player's ID you just healed and then check if the player ID you want to heal now is the same as before, like this:
Код:
new LastPlayerHealed[MAX_PLAYERS];

//in command:
if(LastPlayerHealed[playerid] == targetid) //or something other than targetid for the target^^ depends on your command code
{
	return SendClientMessage(playerid, -1, "You can't heal this player twice. Please heal another player first!");
}
LastPlayerHealed[playerid] = targetid;
thanks for replying, but i have already tried that, this is kinda bugged.

Reason: (example)
1. /heal 3 (Message: You healed him successfuly)
2. ID 3 left the game.
3. another player joined the game with id 3
4. /heal 3 (Message: you can't heal id 3 two times in row)

so i want a method to save LastPlayerHealed as a "NAME" not ID :)
Reply
#10

Okay, here new version:

Код:
	    if(LastPlayerHealed[playerid][0])
	    {
		    if(strcmp(LastPlayerHealed[playerid], NAME_OF_TARGET, true) == 0)
		    {
		        new str[128];
		        format(str,sizeof(str),"You already healed %s once! Please heal another player first!",LastPlayerHealed[playerid]);
		        SendClientMessage(playerid,-1,str);
		        return 1;
		    }
	    }
		format(LastPlayerHealed[playerid],128,"%s",NAME_OF_TARGET);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)