/kill? But not the suicide one...
#1

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...
Reply
#2

Do you have strtok?
Reply
#3

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

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:
Reply
#5

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;
  }

Reply
#6

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
Reply
#7

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

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..");
Reply
#9

Thats the way i code in every language so sue me
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)