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



cmd /kill with time - BenStar - 10.03.2018

#include <a_samp>

#define COLOR_RED 0xFF0000FF


public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 5) == 0)
{
SendClientMessage(playerid, COLOR_RED, "You will be dead after 15 seconds");
SetTimer("kill", 15000, false);
SetPlayerHealth(playerid, 0.0);
return 1;

}

return 0;
}


how to set time to this for 15 seconds SetTimer("kill", 15000, false); not working


Re: cmd /kill with time - David (Sabljak) - 10.03.2018

Example

Код:
#include <a_samp>

#define COLOR_RED 0xFF0000FF

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/kill", cmdtext, true, 5) == 0)
	{
		SendClientMessage(playerid, COLOR_RED, "You will be dead after 15 seconds");
		SetTimerEx("kill", 15000, false, "i", playerid);
		return 1;
	}
	return 0;
}

forward kill(id);
public kill(id)
{
    SetPlayerHealth(id, 0.0);
    SendClientMessage(id, COLOR_RED, "15 seconds passed, you are dead");
    return 1;
}



Re: cmd /kill with time - RxErT - 10.03.2018

PHP код:
#include <a_samp>
#define COLOR_RED 0xFF0000FF
forward Dead(playerid);
public 
Dead(playerid)
{
  
SetPlayerHealth(playerid0.0);
  return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
  if (
strcmp("/kill"cmdtexttrue5) == 0)
    {
      
SendClientMessage(playeridCOLOR_RED"You will be dead after 15 seconds");
      
SetTimerEx("Dead"15000false"i"playerid);
      return 
1;
    }
    return 
0;

NOTE: First, learn how to indent your code perfectly there are a bunch of tutorial showing how to optimize your code, and why not using ZCMD or IZCMD?

EDIT: Late, someone's already posted above.


Re: cmd /kill with time - BenStar - 10.03.2018

..............................


Re: cmd /kill with time - RxErT - 10.03.2018

Quote:
Originally Posted by BenStar
Посмотреть сообщение
..............................
What's the issue now?