SA-MP Forums Archive
/kill - 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: /kill (/showthread.php?tid=435066)



/kill - WiseRice - 05.05.2013

I want a command which when u write /kill u cant write it again for another 5 mins.

Код:
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		SetPlayerHealth(playerid, 0);
		GameTextForPlayer(playerid, "~w~Grim Reaper~n~~r~Has Taken Your Soul!", 4500, 2);
		return 1;
	}



Re: /kill - WiseRice - 05.05.2013

can some help?


Re: /kill - Rillo - 05.05.2013

At the top of the script;
Код:
new Kill[MAX_PLAYERS] = 1;
Somewhere in script;
Код:
forward KillTimer(playerid);
public KillTimer(playerid)
{
	Kill[playerid] = 1;
	return 1;
}
Код:
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
              If (Kill[playerid] == 1)
             {
		SetPlayerHealth(playerid, 0);
		GameTextForPlayer(playerid, "~w~Grim Reaper~n~~r~Has Taken Your Soul!", 4500, 2);
                SetTimerEx("KillTimer", 1000*60*5, false, "i", playerid);
                Kill[playerid] = 0;
            }
		else return SendClientMessage(playerid, 0xFF0000FF, "You can only use this command once every 5 minutes!");
               return 1;
	}
I think that's about right.


Re: /kill - Pottus - 05.05.2013

pawn Код:
new KillCommandTime[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
                if(GetTickCount() - KillCommandTime[playerid] > 300000)
                {
                    KillComandTime[playerid] = GetTickCount();  
            SetPlayerHealth(playerid, 0);
            GameTextForPlayer(playerid, "~w~Grim Reaper~n~~r~Has Taken Your Soul!", 4500, 2);
                    KillCommandTime[playerid] = GetTickCount();
                }
                return 1;
    }
}

public OnPlayerDisconnect(playerid)
{
    KillCommandTime[playerid] = 0;
}
@Rillo: A timer? That is the worst way to do it! Not to mention this SetTimerEx("KillTimer", 1000*60*5, false, "i", playerid); is more on the order of 5 minutes 30 seconds.


Re: /kill - BigGroter - 05.05.2013

Use timestamps