anti-class switch delay
#1

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.
Reply
#2

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");
}
Reply
#3

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
Reply
#4

Cessil is right. Better change it to onplayertakedamage. But I hope some fix this code. Thanks and looking forward to any reply.
Reply
#5

do it yourself, if not post in the script request thread, this section is for helping people that want to learn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)