SA-MP Forums Archive
Public function and playerid - 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: Public function and playerid (/showthread.php?tid=323962)



Public function and playerid - falor - 07.03.2012

Hey guys,

i make a public function, but it works only for id 0, and it does nothing for other ids any idea?

Код:
new Tutonumber[MAX_PLAYERS];
Код:
forward tutorial(playerid);
Onplayerspawn i set :
Код:
SetTimer("Tutorial", 25000, false);
And the function :

Код:
public Tutorial(playerid)
{
    new pname[24], string[128]; 
    GetPlayerName(playerid, pname, 24); 
	if(Tutonumber[playerid] == 0)
	{
    format(string, 128, "-------------------XXXXXXXX %s----------------------", pname);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	format(string, 128, "XXXXXXXXXXXXXXXXXXX");
	SendClientMessage(playerid,COLOR_WHITE, string);
	format(string, 128, "XXXXXXXXXXXXXXXXXXXXXXX");
	SendClientMessage(playerid,COLOR_WHITE, string);
 	format(string, 128, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
	SendClientMessage(playerid,COLOR_WHITE, string);
	format(string, 128, "----------------------------------------------------------------------------");
	SendClientMessage(playerid,COLOR_YELLOW, string);
	SetTimer("Tutorial", 19000, false);
	Tutonumber[playerid] = 1;
	}
	else if(Tutonumber[playerid] == 1)
	{
	format(string, 128, "---------------------------XXXXXXXXXXXX----------------------------");
	SendClientMessage(playerid,COLOR_YELLOW, string);
	format(string, 128, "----------------------------------------------------------------------------");
	SendClientMessage(playerid,COLOR_YELLOW, string);
	SetTimer("Tutorial", 25000, false);
	Tutonumber[playerid] = 2;
	}
	else if(Tutonumber[playerid] == 2)
	{
	format(string, 128, "---------------------------XXXXXXXXXXXXXXXXX--------------------------------");
	SendClientMessage(playerid,COLOR_YELLOW, string);
	format(string, 128, "----------------------------------------------------------------------------");
	SendClientMessage(playerid,COLOR_YELLOW, string);
	SetTimer("Tutorial", 25000, false);
	Tutonumber[playerid] = 3;
	}
	else if(Tutonumber[playerid] == 3)
	{
	SendClientMessage(playerid,COLOR_GREY, string);
	format(string, 128, "XXXXXXXXXXXXXXXX%s.", pname);
	SetTimer("OnPlayerSpawn", 100, false);
	}
	return 1;
}
And moreover, i set : SetPlayerColor(playerid, COLOR_WHITE); in OnPlayerConnect

But i seems that players got random name color...


Who can help me please?

Thanks


Re: Public function and playerid - Ballu Miaa - 07.03.2012

You should use it like:
pawn Код:
//Anywhere in your game mode
new tutorialtimer[MAX_PLAYERS];
//Add this where you want to start the timer at!
tutorialtimer = SetTimerEx("Tutorial", 25000, 0, "i", playerid);
// You can kill the timer where you want as like this.
KillTimer(tutorialtimer);



Re : Public function and playerid - falor - 07.03.2012

Thanks for you fast help!!


Re: Re : Public function and playerid - Ballu Miaa - 07.03.2012

Quote:
Originally Posted by falor
Посмотреть сообщение
Thanks for you fast help!!
All good brother. Thanks for the rep.