help me guys - 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: help me guys (
/showthread.php?tid=655282)
help me guys -
GameOvr - 17.06.2018
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.
Re: help me guys -
Lokii - 17.06.2018
SetTimerEx(funcname[], interval, repeating, const format[], {Float,_}:...)
PHP код:
CMD:kill(playerid)
{
SendClientMessage(playerid, 0xFF0000FF, "wait 10 seconds to suicide");
SetTimerEx("KILLPLAYER", 10000, false, "i", playerid);
return 1;
}
forward KILLPLAYER(playerid);
public KILLPLAYER(playerid)
{
SetPlayerHealth(playerid, 0.0);
}
Re: help me guys -
GameOvr - 17.06.2018
Thank u I will definitely try this out +rep
Re: help me guys -
CaptainBoi - 17.06.2018
PHP код:
new killtimer[MAX_PLAYERS];
CMD:kill(playerid)
{
SendClientMessage(playerid, 0xFF0000FF, "wait 10 seconds to suicide");
killtimer[playerid] = SetTimerEx("killhim", 10000, false, "i", playerid);
return 1;
}
forward killhim(playerid);
public killhim(playerid)
{
SetPlayerHealth(playerid, 0.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.
Re: help me guys -
TheBeastKhan - 17.06.2018
Quote:
Originally Posted by CaptainBoi
PHP код:
new killtimer[MAX_PLAYERS];
CMD:kill(playerid)
{
SendClientMessage(playerid, 0xFF0000FF, "wait 10 seconds to suicide");
killtimer[playerid] = SetTimerEx("killhim", 10000, false, "i", playerid);
return 1;
}
forward killhim(playerid);
public killhim(playerid)
{
SetPlayerHealth(playerid, 0.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...
Re: help me guys -
Lucases - 17.06.2018
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