SA-MP Forums Archive
Simple question... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Simple question... (/showthread.php?tid=250961)



Simple question... - [JnA]DukeNukem - 25.04.2011

I want to delay a message with a timer on player spawn

so i want to wait about 3 seconds after player spawns, then he recieves a message "welcome"

help me please


Re: Simple question... - xRyder - 25.04.2011

Edit: Woops, sorry I misread.

Use SetTimerEx.


Re: Simple question... - [JnA]DukeNukem - 25.04.2011

I have... like this but it isn't working

Код:
SetTimerEx("WelcomeDelay", 10, true, "i", playerid);
		 SetPlayerPos(playerid, PVar[playerid][pLastX], PVar[playerid][pLastY], PVar[playerid][pLastZ]);
		 SetPlayerSkin(playerid,PVar[playerid][pDeaths]);
		 SendClientMessage(playerid,COLOR_GREEN, " Welcome");



Re: Simple question... - xRyder - 25.04.2011

Alright, I made this just for example.

pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("Wait"/*Name of the Function/Timer*/, 3000/*Time - 3sec*/, false/*It will not repeate*/,/*You're sending players ID as a parameter ->*/ "i", playerid);
    return 1;
}

forward Wait(playerid);
public Wait(playerid)
{
    SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to my server!");
    return 1;
}



Re: Simple question... - [JnA]DukeNukem - 25.04.2011

G:\DOCUME~1\Admin\Desktop\SAMP\FILTER~1\COPYOF~1.P WN(187) : warning 202: number of arguments does not match definition
G:\DOCUME~1\Admin\Desktop\SAMP\FILTER~1\COPYOF~1.P WN(219) : error 029: invalid expression, assumed zero
G:\DOCUME~1\Admin\Desktop\SAMP\FILTER~1\COPYOF~1.P WN(219) : error 017: undefined symbol "Wait"
G:\DOCUME~1\Admin\Desktop\SAMP\FILTER~1\COPYOF~1.P WN(220) : error 029: invalid expression, assumed zero
G:\DOCUME~1\Admin\Desktop\SAMP\FILTER~1\COPYOF~1.P WN(220) : error 017: undefined symbol "Wait"

Код:
public OnPlayerSpawn(playerid)
{
	if(PVar[playerid][pLastX] == 0.0 && PVar[playerid][pLastY] == 0.0)
	{
		new
		    RPos = random(sizeof(RandSpawns));

		
		SetPlayerPos(playerid, RandSpawns[RPos][0], RandSpawns[RPos][1], RandSpawns[RPos][2]);
	}
	else
         {
    SetTimerEx("Wait"/*Name of the Function/Timer*/, 3000/*Time - 3sec*/, false/*It will not repeate*/,/*You're sending players ID as a parameter ->*/ "i", playerid);
    return 1;
}

	forward Wait(playerid);
	public Wait(playerid)
	{
    	SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to my server!");
    	return 1;
	}
		return 1;
}



Re: Simple question... - xRyder - 25.04.2011

Wow! You messed up a lot of things.

+ You shouldn't forward/create new function in premaded one...

It should be like:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PVar[playerid][pLastX] == 0.0 && PVar[playerid][pLastY] == 0.0)
    {
        new RPos = random(sizeof(RandSpawns));
        SetPlayerPos(playerid, RandSpawns[RPos][0], RandSpawns[RPos][1], RandSpawns[RPos][2]);
    }
    else
    {
        SetTimerEx("Wait"/*Name of the Function/Timer*/, 3000/*Time - 3sec*/, false/*It will not repeate*/,/*You're sending players ID as a parameter ->*/ "i", playerid);
    }
    return 1;
}

forward Wait(playerid);
public Wait(playerid)
{
    SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to my server!");
    return 1;
}



Re: Simple question... - [JnA]DukeNukem - 25.04.2011

Now it compiles, but the message doesn't show..... darn...


Re: Simple question... - xRyder - 25.04.2011

Try using 'print' and see if the timer gets called. Also, check if your 'PVar[playerid][pLastX]' or 'PVar[playerid][pLastY]' is not 0.00.


Re: Simple question... - [JnA]DukeNukem - 25.04.2011

The Var's can't be 0 because it's the last know position of the player, i did printf, but nothing happened