SA-MP Forums Archive
/kill? But not the suicide one... - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /kill? But not the suicide one... (/showthread.php?tid=71792)



/kill? But not the suicide one... - FrazZ - 03.04.2009

Anyone have a code for /kill2 but you dont kill yourself you do:

/kill2 (playerid) (Reason)
if its your id
You cant kill yourself!

the reason why its /kill2 is because i have a code that suicides you with /kill...


Re: /kill? But not the suicide one... - MenaceX^ - 03.04.2009

Do you have strtok?


Re: /kill? But not the suicide one... - FrazZ - 03.04.2009

Never mind, a scripter is doing it for me please delete or lock


Re: /kill? But not the suicide one... - ICECOLDKILLAK8 - 03.04.2009

pawn Код:
// You will need: strtok, ReturnUser
// Top of OnPlayerCommandText
new idx;
new tmp[128];
new cmd[128];
cmd = strtok(cmdtext, idx);

// Command
if(strcmp(cmd, "/kill2", true) == 0)
{
  tmp = strtok(cmdtext,idx);
  if(!strlen(tmp))
  {
    SendClientMessage(playerid, color, "Usage: /kill2 [playerid/name]");
    return 1;
  }
  new player = ReturnUser(tmp);
  SetPlayerHealth(player, 0);
  return 1;
}
EDIT: Oops didnt see your reply D:


Re: /kill? But not the suicide one... - MenaceX^ - 03.04.2009

Quote:
Originally Posted by JeNkStAX
pawn Код:
// Top of OnPlayerCommandText
new idx;
new tmp[128];
new cmd[128];
cmd = strtok(cmdtext, idx);

// Command
if(strcmp(cmd, "/kill2", true) == 0)
{
  tmp = strtok(cmdtext,idx);
  if(!strlen(tmp))
  {
    SendClientMessage(playerid, color, "Usage: /kill2 [playerid/name]");
    return 1;
  }
  new player = ReturnUser(tmp);
  SetPlayerHealth(player, 0);
  return 1;
}
I'd like to make it, that's why I asked if he has strtok.
Also same about ReturnUser. (which could be done with strval instead.)
But I don't get it, JeNkStAX.
Why do you use the usage like that?
pawn Код:
if(!strlen(tmp))
  {
    SendClientMessage(playerid, color, "Usage: /kill2 [playerid/name]");
    return 1;
  }




Re: /kill? But not the suicide one... - ICECOLDKILLAK8 - 03.04.2009

Strlen gets the size of a string (At least it does in C++) so putting a ! in front of it would detect if it was 0 which means they didnt type anything after the command


Re: /kill? But not the suicide one... - LarzI - 03.04.2009

I think he means the part "[playerid/name]"


Re: /kill? But not the suicide one... - MenaceX^ - 03.04.2009

Quote:
Originally Posted by lrZ^ aka LarzI
I think he means the part "[playerid/name]"
Not really.
I honestly think it's a long and stupid way..
pawn Код:
if(!strlen(tmp))
  {
    SendClientMessage(playerid, color, "Usage: /kill2 [playerid/name]");
    return 1;
  }
pawn Код:
//I like for short messages to do like
if(!strlen(something)) return SendClientMessage(playerid,color,"USAGE: /kill2 [playerid/name]");
If it's longer.
pawn Код:
if(!strlen(something))
  return SendClientMessage(playerid,color,"usage: /usemebecausei'malongmessageandihatetomakesuchalongmessageinthesameline..");



Re: /kill? But not the suicide one... - ICECOLDKILLAK8 - 03.04.2009

Thats the way i code in every language so sue me


Re: /kill? But not the suicide one... - Donvalley - 03.04.2009

This Is More Fun I Think:

Код:
if(strcmp(cmd, "/nuke", true) == 0)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
			{
				SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /nuke [playerid]");
				SendClientMessage(playerid, 0xC0C0C0FF, "FUNCTION: Player will explode.");
				return 1;
			}
			new Float:X,Float:Y,Float:Z;
			giveplayerid = strval(tmp);
			  if(IsPlayerConnected(giveplayerid))
			  {
						GetPlayerPos(giveplayerid, X,Y,Z);
			      CreateExplosion(X,Y,Z,2,7.0);
						SetPlayerHealth(giveplayerid, 0.0);
						format(string, sizeof(string), "%d Got Nuked!",giveplayer);
						SendClientMessage(playerid, 0x21DD00FF, string);
				}
				else if (!IsPlayerConnected(giveplayerid))
				{
					format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, 0xE60000FF, string);
				}
  }
	else
	{
	SendClientMessage(playerid, 0xE60000FF, "You're not an admin.");
	}
return 1;
}