SA-MP Forums Archive
[Help] /cuff problem - 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: [Help] /cuff problem (/showthread.php?tid=80965)



[Help] /cuff problem - joeri55 - 07.06.2009

Hello guys,

This is my /cuff command:

pawn Код:
if(!strcmp(cmd,"/cuff",true))
    {
        cmd=strtok(cmdtext,idx);
        if(!strlen(cmd)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /cuff playerid");
        id=ReturnUser(cmd);
        if(!IsPlayerConnected(layerid)) return SendClientMessage(playerid,COLOR_GREY,"Invalid player id.");
        TogglePlayerControllable(layerid,0);
        GameTextForPlayer(playerid, "~y~ hand cuffs!",2500,3);
        return true;
    }

But if I compile it some errors pops up:
Quote:

C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(9256) : error 017: undefined symbol "id"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(9256) : error 017: undefined symbol "ReturnUser"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(9257) : error 017: undefined symbol "layerid"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(925 : error 017: undefined symbol "layerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Does anyone has a idea of what I'm doing wrong?


Re: [Help] /cuff problem - Weirdosport - 07.06.2009

Read the errors, you obviously misspelled playerid, that gets rid of 2 of them...


Re: [Help] /cuff problem - joeri55 - 07.06.2009

But what about the layerid and the other one?


Re: [Help] /cuff problem - member - 07.06.2009

Quote:
Originally Posted by joeri55
But what about the layerid and the other one?
Did u even read what Weirdosport said? change 'layerid' to 'playerid'


Re: [Help] /cuff problem - joeri55 - 07.06.2009

ok


Re: [Help] /cuff problem - samgreen - 07.06.2009

pawn Код:
if(!strcmp(cmd,"/cuff",true)) {
  // Declare and initialize variables to hold parameters
  new playerToBeCuffed[256], playerCuffedID, index;
  playerToBeCuffed = strtok(cmdtext, index);

  // Do we have valid parameters? This implementation is much faster than checking the string length of the command.
  if(!playerToBeCuffed[0]) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /cuff [Player ID / Part of name]");

  // Did they specify id, or name?
  if(!IsNumeric(playerToBeCuffed)) {
    playerCuffedID = ReturnPlayerID(playerToBeCuffed);
  } else playerCuffedID = strval(playerToBeCuffed);

  // Inform the player
  GameTextForPlayer(id, "~y~hand cuffs!", 2500, 3);

  // Toggle the player uncontrollable
  TogglePlayerControllable(id, 0);

  return true;
}
I have basically rewritten this command for you, but there are still a few missing pieces. You need to verify the team of the playerid executing the command, otherwise any player has access to your cuff command.

Please don't just copy and paste this code. LEARN from it. I will check this thread to answer any questions you have.


Re: [Help] /cuff problem - joeri55 - 07.06.2009

Thanks samgreen.
I know that my team is 2.
Where must I add this line: if (gTeam[playerid] == 2) to make it cop only?


Re: [Help] /cuff problem - samgreen - 07.06.2009

Quote:
Originally Posted by joeri55
Thanks samgreen.
I know that my team is 2.
Where must I add this line: if (gTeam[playerid] == 2) to make it cop only?
I would add it before the parameters are verified (before the SendClientMessage), adding it here will also hide the usage from players on other teams.


Re: [Help] /cuff problem - joeri55 - 07.06.2009

sam if I use your code it says:

pawn Код:
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19244) : error 017: undefined symbol "IsNumeric"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19245) : error 017: undefined symbol "ReturnPlayerID"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19249) : error 017: undefined symbol "id"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19252) : error 017: undefined symbol "id"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19246) : warning 204: symbol is assigned a value that is never used: "playerCuffedID"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: [Help] /cuff problem - joeri55 - 07.06.2009

I fixed the id problem by putting player infront of it but still I get this:

pawn Код:
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19244) : error 017: undefined symbol "IsNumeric"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19245) : error 017: undefined symbol "ReturnPlayerID"
C:\Documents and Settings\Joeri\Bureaublad\samp server\gamemodes\penls.pwn(19246) : warning 204: symbol is assigned a value that is never used: "playerCuffedID"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.