help me guys
#1

I'm a new scripter so I need ur help ,
Can anyone send me a code for /kill command with a 10 s of time
IK how to make kill command without timer but I need that command with timer like while player type /kill he receiving a client message by saying wait 10 seconds to suicide.WAITING FOR REPLIES
THANKS.
Reply
#2

SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...)

PHP код:
CMD:kill(playerid)
{
    
SendClientMessage(playerid0xFF0000FF"wait 10 seconds to suicide");
    
SetTimerEx("KILLPLAYER"10000false"i"playerid);
    return 
1;
}
forward KILLPLAYER(playerid);
public 
KILLPLAYER(playerid)
{
    
SetPlayerHealth(playerid0.0);

Reply
#3

Thank u I will definitely try this out +rep
Reply
#4

PHP код:
new killtimer[MAX_PLAYERS];
CMD:kill(playerid

    
SendClientMessage(playerid0xFF0000FF"wait 10 seconds to suicide"); 
    
killtimer[playerid] = SetTimerEx("killhim"10000false"i"playerid); 
    return 
1


forward killhim(playerid); 

public 
killhim(playerid

    
SetPlayerHealth(playerid0.0); 
}  
//Onplayerdisconnect
KillTimer(killtimer); 
you have make it like this what if that player disconnects the server in timeout or something so that timer get kill otherwise the next player will join with that id will get killed as he spawns.
Reply
#5

Quote:
Originally Posted by CaptainBoi
Посмотреть сообщение
PHP код:
new killtimer[MAX_PLAYERS];
CMD:kill(playerid

    
SendClientMessage(playerid0xFF0000FF"wait 10 seconds to suicide"); 
    
killtimer[playerid] = SetTimerEx("killhim"10000false"i"playerid); 
    return 
1

forward killhim(playerid); 
public 
killhim(playerid

    
SetPlayerHealth(playerid0.0); 
}  
//Onplayerdisconnect
KillTimer(killtimer); 
you have make it like this what if that player disconnects the server in timeout or something so that timer get kill otherwise the next player will join with that id will get killed as he spawns.
No it won't, the first one is hell fine, Becoz he got SetTimerEx(*Code*, playerid)
The playerid in it will kill only the Playerid...
Reply
#6

Quote:
Originally Posted by TheBeastKhan
Посмотреть сообщение
No it won't, the first one is hell fine, Becoz he got SetTimerEx(*Code*, playerid)
The playerid in it will kill only the Playerid...
What? If the timer starts with the player id 2 as parameter and while it's running the player with ID 2 logs out and another one logs in he will get killed.

Simply add this:

Код:
public OnPlayerDisconnect(playerid, reason)
{
         KillTimer(killtimer[playerid]);
         killtimer[playerid] = -1;
         return 1;
}
Assuming that you have defined ' killtimer ' variable
Otherwise add this at the top of your script:

Код:
new killtimer[MAX_PLAYERS];
Another thing
You shouldn't give to the players the possibility to spam that command because they can start many timers and I guess you don't want that

So add a small check under your command
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)