SA-MP Forums Archive
Why wont this command work ? :S - 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: Why wont this command work ? :S (/showthread.php?tid=127531)



Why wont this command work ? :S - boelie - 13.02.2010

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



Re: Why wont this command work ? :S - dice7 - 13.02.2010

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



Re: Why wont this command work ? :S - mansonh - 13.02.2010

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


Re: Why wont this command work ? :S - woot - 13.02.2010

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.


Re: Why wont this command work ? :S - mansonh - 13.02.2010

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.


Re: Why wont this command work ? :S - boelie - 13.02.2010

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


Re: Why wont this command work ? :S - NewYorkRP - 13.02.2010

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.


Re: Why wont this command work ? :S - boelie - 13.02.2010

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