[Help] /cuff problem
#1

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

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

But what about the layerid and the other one?
Reply
#4

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

ok
Reply
#6

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

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

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)