anti-class switch delay - 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: anti-class switch delay (
/showthread.php?tid=479564)
anti-class switch delay -
gotwarzone - 05.12.2013
I want to make delay of 5 seconds after a player use /class command to prevent anti-kill or anti class selection. When he use /class there should be a text "Please wait 5 seconds blah blah" then after 5 seconds return player to class selection. If the player got hit while 5 seconds is still counting then cancel the class selection and send him a text "Your class selection has been interupted"
Coz Mostly people with low hp use /class or /changeclass to prevent deaths.
Re: anti-class switch delay -
Tayab - 06.12.2013
I am not sure if I made it correctly but here you go. Hope it helps
pawn Код:
new Spawned[MAX_PLAYERS];
new SpawnEnd[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Spawned[playerid] = 0;
}
CMD:class(playerid,params[])
{
if(Spawned[playerid] == 1) return SendClientMessage(playerid,0xCCCCCCFF,"Please wait for 5 seconds.");
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid,true);
TogglePlayerSpectating(playerid,false);
SetPlayerHealth(playerid,100);
Spawned[playerid] = 1;
SpawnEnd[playerid] = SetTimer("EndSpawned",5000,0);
SetTimer("CheckHit",1000,0);
}
forward CheckHit();
public CheckHit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(GetPlayerHealth(i) < 100)
SendClientMessage(playerid,0xFFFFFF00,"Your class selection has been interupted");
KillTimer(SpawnEnd[playerid]);
}
forward EndSpawned();
public EndSpawned()
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(Spawned[i] == 1)
Spawned[i] = 0;
SendClientMessage(i,0xFF0000FF,"You can now use /class");
}
Re: anti-class switch delay -
cessil - 06.12.2013
use a timer, if they take damage (detected via OnPlayerTakeDamage) kill the timer, send a message and restart the timer, also don't forget to take into account them dying
Re: anti-class switch delay -
gotwarzone - 06.12.2013
Cessil is right. Better change it to onplayertakedamage. But I hope some fix this code. Thanks and looking forward to any reply.
Re: anti-class switch delay -
cessil - 07.12.2013
do it yourself, if not post in the script request thread, this section is for helping people that want to learn