SA-MP Forums Archive
Timer for announcement - 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: Timer for announcement (/showthread.php?tid=641828)



Timer for announcement - DarknesS1988 - 21.09.2017

Need help about SetTimerEx. I want to set timer on Welcome Message(SendClientAnnouncement). When player join, this message will have to pop up after 10seconds (10000 miliseconds).

Here's the code:
PHP код:
if (PlayerInfo[playerid][pFirstSpawn] == 0)
    {
    
PlayerInfo[playerid][pFirstSpawn] = 1;
    
SendClientOnScreenText(playerid,MOTD);
    
SendClientMessage(playeridCOLOR_SERVER_MAIN_MSG"{FF66FF}THIS ISN'T DEATHMATCH - NO RANDOM KILLING!  {FFFFFF}Follow the rules or be {FF0000}Kicked{FFFFFF}!");
format(stringsizeof(string), "Welcome To ~y~%s~n~~b~%s~n~~w~Type ~y~/help~w~, ~y~/rules ~w~or~n~~y~/cmds ~w~For Game Info",ServerInfo[sMapName],PlayerInfo[playerid][pName]);
    
SendClientAnnouncement(playerid,string);
    
    
    }
//SpawnCheck
    
PlayerInfo[playerid][pResume] = 1;
    
PlayerInfo[playerid][pSpawn] = 1;
    }
//SpectateCheck
    
    
}//NPCCheck
    
return 1;

I know that I need to put this somewhere, but where exactly?

PHP код:
SetTimerEx("WelcomeTimer"10000false"i"playerid);
}
forward WelcomeTimer(playerid);
public 
WelcomeTimer(playerid
I will give reputation for help.
Thanks


Re: Timer for announcement - Twizted - 21.09.2017

pawn Код:
SetTimerEx("WelcomeTimer", 10000, false, "i", playerid);
Put it under OnPlayerConnect if you want to show the message 10 seconds after the player connects to the server. Put it under OnPlayerSpawn if you want to show the message 10 seconds after the player spawns (if you're using the SpawnPlayer function).


Re: Timer for announcement - DarknesS1988 - 21.09.2017

Yes, I have onplayerspawn...
You mean like this:

PHP код:
SetTimerEx("WelcomeTimer"10000false"i"playerid);
    }
    
forward WelcomeTimer(playerid);
    public 
WelcomeTimer(playerid)
    {
    
format(stringsizeof(string), "Welcome To ~y~%s~n~~b~%s~n~~w~Type ~y~/help~w~, ~y~/rules ~w~or~n~~y~/cmds ~w~For Game Info",ServerInfo[sMapName],PlayerInfo[playerid][pName]);
    
SendClientAnnouncement(playerid,string); 
but then i got this:
PHP код:
D:\...(11152) : error 029invalid expressionassumed zero
D
:\...(11152) : error 017undefined symbol "WelcomeTimer"
D:\...(11153) : error 029invalid expressionassumed zero
D
:\...(11153) : error 017undefined symbol "WelcomeTimer"
D:\...(11173) : error 054unmatched closing brace ("}")
D:\...(11175) : error 010invalid function or declaration 



Re: Timer for announcement - Twizted - 21.09.2017

Do you have this part inside OnPlayerSpawn?

pawn Код:
forward WelcomeTimer(playerid);
    public WelcomeTimer(playerid)
    {
    format(string, sizeof(string), "Welcome To ~y~%s~n~~b~%s~n~~w~Type ~y~/help~w~, ~y~/rules ~w~or~n~~y~/cmds ~w~For Game Info",ServerInfo[sMapName],PlayerInfo[playerid][pName]);
    SendClientAnnouncement(playerid,string);
If you do, remove it from there and put it elsewhere, outside of a callback.


Better yet, post your OnPlayerSpawn callback here.


Re: Timer for announcement - DarknesS1988 - 21.09.2017

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Do you have this part inside OnPlayerSpawn?

pawn Код:
forward WelcomeTimer(playerid);
    public WelcomeTimer(playerid)
    {
    format(string, sizeof(string), "Welcome To ~y~%s~n~~b~%s~n~~w~Type ~y~/help~w~, ~y~/rules ~w~or~n~~y~/cmds ~w~For Game Info",ServerInfo[sMapName],PlayerInfo[playerid][pName]);
    SendClientAnnouncement(playerid,string);
If you do, remove it from there and put it elsewhere, outside of a callback.


Better yet, post your OnPlayerSpawn callback here.
Done! I've putted outside of callback and it's working now!
Thank you alot! Reputation Earned!


Re: Timer for announcement - Twizted - 21.09.2017

Great. For future reference, whenever you are declaring a function, you must not but it inside a callback. Always put it ouside the callback.