Why wont this command work ? :S
#1

Hello, i made this command here i realy thought it would work but it isnt doing anything.
Can anyone help me please ?
Im making more commands like this, that a player who use a command has to check if another player is near
i just need to know how to check the other player and use it in a correct way.

Код:
  if(!strcmp(cmdtext, "/rape", true))
	{
	new kidnapvehicle;
	kidnapvehicle = GetPlayerVehicleID(playerid);
	new playername[MAX_PLAYER_NAME];
 	GetPlayerName(playerid,playername,sizeof(playername));
 	new tmp[64];
	new victimname[16];
 	new victim;
	victim = strval(tmp);
	GetPlayerName(victim, victimname, sizeof(victimname));
	if(GetDistanceBetweenPlayers(playerid,victim) < 4 )
	{
	SetPlayerHealth(victim, 9);
	SendClientMessage(victim,COLOR_RED,"You have been raped");
	}
	if(IsPlayerInVehicle(victim, kidnapvehicle))
	{
  SetPlayerHealth(victim, 9);
	SendClientMessage(victim,COLOR_RED,"You have been raped");
	}
	return 1;
	}
Reply
#2

pawn Код:
victim = strval(strtok(cmdtext, idx));
Reply
#3

Also its not
if(!strcmp(cmdtext, "/rape", true))
its
if(strcmp(cmdtext, "/rape", true))
Reply
#4

Quote:
Originally Posted by mansonh
Also its not
if(!strcmp(cmdtext, "/rape", true))
its
if(strcmp(cmdtext, "/rape", true))
No, strcmp returns 0 if the strings are equal, and 1 if the strings are not equal.
Reply
#5

Quote:
Originally Posted by //exora
Quote:
Originally Posted by mansonh
Also its not
if(!strcmp(cmdtext, "/rape", true))
its
if(strcmp(cmdtext, "/rape", true))
No, strcmp returns 0 if the strings are equal, and 1 if the strings are not equal.
meh!
Nm, looking at a diff version.
I don't use it normally.
Reply
#6

WooW ..okay its still not working anyway im afraid :S very weird.
Would it be easyer if i want it to work with pressing a key ?

lets say under onplayerkeystatechange

if ((newkeys & 12 && (newkeys & 16))
{

..rest of the script
Reply
#7

pawn Код:
if(strcmp(cmd, "/rape", true) == 0)
    {
      GetPlayerName(playerid, sendername, sizeof(sendername));
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GREY, "/rape [Playerid]");
            return 1;
        }
        giveplayerid = strval(tmp);
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(IsPlayerConnected(giveplayerid))
        {
            if(GetDistanceBetweenPlayers(playerid,giveplayerid) < 4)
            {
              if(IsPlayerConnected(giveplayerid))
              {
                    SendClientMessage(giveplayerid, COLOR_RED, "You have been raped!");
                    SetPlayerHealth(giveplayerid, 9);
                }
                else
                {
                  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                    SendClientMessage(playerid, COLOR_RED, string);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You are not close enough to that person!");
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
        }
        return 1;
    }

- Edit to your liking with the veh, and position, etc.
Reply
#8

thanks but i dont want it to be a function that you also need to type the players id
i want it to do that automaticly
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)