SA-MP Forums Archive
[Help]Guys i need help plz with jail command - 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]Guys i need help plz with jail command (/showthread.php?tid=173573)



[Help]Guys i need help plz with jail command - zack3021 - 03.09.2010

I made a jail command. But when i type it, it jails me and not the player.

Код:
	if (strcmp("/jail", cmdtext, true, 10) == 0)
	{
		SetPlayerPos(playerid,2042.7137,988.9628,10.6719);
		return 1;
	}
  	return 0;
}



Re: [Help]Guys i need help plz with jail command - Lilcuete - 03.09.2010

Quote:
Originally Posted by zack3021
Посмотреть сообщение
I made a jail command. But when i type it, it jails me and not the player.

Код:
	if (strcmp("/jail", cmdtext, true, 10) == 0)
	{
		SetPlayerPos(playerid,2042.7137,988.9628,10.6719);
		return 1;
	}
  	return 0;
}
Use this
Код:
if (strcmp("/jail", cmdtext, true, 10) == 0)
	{
      tmp = strtok(cmdtext, idx);
                if(!strlen(tmp)) {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /jail [playerid]");
                    return 1;
                }
                new playa;
                playa = ReturnUser(tmp);
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp)) {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /jail [playerid]");
                    return 1;
                }
               SetPlayerPos(playa,2042.7137,988.9628,10.6719);
              return 1;
              }
}



Re: [Help]Guys i need help plz with jail command - Toni - 03.09.2010

Quote:
Originally Posted by zack3021
Посмотреть сообщение
I made a jail command. But when i type it, it jails me and not the player.

Код:
	if (strcmp("/jail", cmdtext, true, 10) == 0)
	{
		SetPlayerPos(playerid,2042.7137,988.9628,10.6719);
		return 1;
	}
  	return 0;
}
Don't use the code above; it has missing things that you need in order to use that.

Yes, thats because you put "playerid" which means you are telling the script to jail the person typing the cmd.

You need to use strtok; or sscanf.

Under OnPlayerCommandText:
pawn Код:
new
        cmd[256],
        tmp[256],
        idx
    ;
    cmd = strtok(cmdtext, idx);
    if(!strcmp(cmd, "/jail", true))
    {
        new id;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail <id>");
       
        id = strval(tmp);
       
        SetPlayerPos(id, 2042.7137,988.9628,10.6719);
        return 1;
    }
Your welcome


Re: [Help]Guys i need help plz with jail command - zack3021 - 03.09.2010

I get errors

Should i add to the top new(then whatever is new)

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(56) : error 017: undefined symbol "cmdtext"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(58) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(58) : error 017: undefined symbol "strtok"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(59) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(59) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(60) : error 017: undefined symbol "COLOR_GRAD2"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(64) : error 017: undefined symbol "ReturnUser"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(65) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(65) : error 017: undefined symbol "strtok"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(66) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(67) : error 017: undefined symbol "COLOR_GRAD2"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(70) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(71) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(73) : warning 209: function "OnPlayerConnect" should return a value
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(74) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


11 Errors.



Re: [Help]Guys i need help plz with jail command - Lilcuete - 03.09.2010

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Yes, thats because you put "playerid" which means you are telling the script to jail the person typing the cmd.

You need to use strtok; or sscanf.

pawn Код:
new
        cmd[256],
        tmp[256],
        idx
    ;
    cmd = strtok(cmdtext, idx);
    if(!strcmp(cmd, "/jail", true))
    {
        new id;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail <id>");
       
        id = strval(tmp);
       
        SetPlayerPos(id, 2042.7137,988.9628,10.6719);
        return 1;
    }
Your welcome
Use this one.


Re: [Help]Guys i need help plz with jail command - zack3021 - 03.09.2010

The errors are not with Toni's script, i need to test his. Sorry for doublepost.


Re: [Help]Guys i need help plz with jail command - zack3021 - 03.09.2010

Here are the errors with Toni's script:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(99) : error 017: undefined symbol "strtok"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(99) : error 033: array must be indexed (variable "tmp")
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(95) : warning 203: symbol is never used: "idx"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\jail.pwn(92) : warning 204: symbol is assigned a value that is never used: "cmd"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: [Help]Guys i need help plz with jail command - mrcoolballs - 03.09.2010

You need the strtok code at the bottom of your script, if i had it on me i would give it to you, im sure somone in here will give it to you


Re: [Help]Guys i need help plz with jail command - zack3021 - 03.09.2010

Thanks and i would love to know what stroke means but for now i will wait for somone to give me


Re: [Help]Guys i need help plz with jail command - Toni - 03.09.2010

Put this at the bottem of your script:
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}