SA-MP Forums Archive
Last Player Function! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Last Player Function! (/showthread.php?tid=499872)



Last Player Function! - AnonScripter - 10.03.2014

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.


Re: Last Player Function! - mahardika - 10.03.2014

use player variable like
new LastPlayerHeal[MAX_PLAYERS];


Re: Last Player Function! - RenovanZ - 10.03.2014

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.


Re: Last Player Function! - AnonScripter - 10.03.2014

no not that what i want


Re: Last Player Function! - RenovanZ - 10.03.2014

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


Respuesta: Re: Last Player Function! - SickAttack - 10.03.2014

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.


Re: Respuesta: Re: Last Player Function! - AnonScripter - 10.03.2014

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.


Re: Last Player Function! - Macronix - 10.03.2014

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;



Re: Last Player Function! - AnonScripter - 10.03.2014

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 :)


AW: Last Player Function! - Macronix - 10.03.2014

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);