How to assign a value
#1

ok when i type /jail i get jail, i understand that any player with the id 0 will get jailed if they type it they get jaild so how can i assign a value to it

Код:
COMMAND:jail(playerid,params[])
{   new pskin = GetPlayerSkin(playerid);
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)

    if(IsPlayerConnected(playerid))
    {
        new pId;

         if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new rand = random(sizeof(JailCellSpawns));
                    SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                    new rand1 = random(sizeof(JailCellSpawns1));
                    SetPlayerPos(pId, JailCellSpawns1[rand1][0], JailCellSpawns1[rand1][1], JailCellSpawns1[rand1][2]);
                    if(GetPlayerWantedLevel(pId) > 3) return SetTimerEx("Unjail",2000,false,"i",pId);
                    InJail[pId] = 1;
                    SetPlayerWantedLevel(pId, 0);
                    return 1;
                }
               }
               else if(GetPlayerSkin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"You dont have permisson to acces this command");
    {
                       return 0;
            }
}
Reply
#2

I use sscanf its easier with that, but try this
pawn Код:
new pId;//swap this bit for yours
pId = strval(params);

EDIT: pid was in wrong case (was lowercase)
Reply
#3

Lol now how to add it to the script?
Reply
#4

Replace:
pawn Код:
if(IsPlayerConnected(playerid))
    {
        new pId;
With:
pawn Код:
new pId;
pId = strval(params);
Or you can't understand this also, if you can't. Just rip-off the jail command from a administration script.
Reply
#5

Guys plz help, this still puts id 0 into jail when he types it
Reply
#6

pawn Код:
new pId = strval(params);
So hard to understand?
Reply
#7

Код:
    if(IsPlayerConnected(playerid))
    {
well obviously he will be connected, use sscanf, its very easy to use
Reply
#8

Ok can you add it for me because when i add it i get an error.

look:
Код:
COMMAND:jail(playerid,params[])
{   new pskin = GetPlayerSkin(playerid);
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)

    new pId = strval(params);
    {
        new pId;

         if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new rand = random(sizeof(JailCellSpawns));
                    SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                    new rand1 = random(sizeof(JailCellSpawns1));
                    SetPlayerPos(pId, JailCellSpawns1[rand1][0], JailCellSpawns1[rand1][1], JailCellSpawns1[rand1][2]);
                    if(GetPlayerWantedLevel(pId) > 3) return SetTimerEx("Unjail",2000,false,"i",pId);
                    InJail[pId] = 1;
                    SetPlayerWantedLevel(pId, 0);
                    return 1;
                }
               }
               else if(GetPlayerSkin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"You dont have permisson to acces this command");
    {
                       return 0;
            }
}
Reply
#9

Quote:
Originally Posted by zack3021
Посмотреть сообщение
Ok can you add it for me because when i add it i get an error.

look:
Код:
COMMAND:jail(playerid,params[])
{   new pskin = GetPlayerSkin(playerid);
    if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)

    new pId = strval(params);
    {
        new pId;

         if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new rand = random(sizeof(JailCellSpawns));
                    SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                    new rand1 = random(sizeof(JailCellSpawns1));
                    SetPlayerPos(pId, JailCellSpawns1[rand1][0], JailCellSpawns1[rand1][1], JailCellSpawns1[rand1][2]);
                    if(GetPlayerWantedLevel(pId) > 3) return SetTimerEx("Unjail",2000,false,"i",pId);
                    InJail[pId] = 1;
                    SetPlayerWantedLevel(pId, 0);
                    return 1;
                }
               }
               else if(GetPlayerSkin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"You dont have permisson to acces this command");
    {
                       return 0;
            }
}
give me the code where you have errror and what error? + what lines?
Reply
#10

Here are the errors:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(85) : error 003: declaration of a local variable must appear in a compound block
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(85) : error 017: undefined symbol "pId"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(89) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(102) : warning 225: unreachable code
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(102) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(102) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(102) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(102) : error 001: expected token: ";", but found "if"
C:\Program Files\Rockstar Games\GTA San Andreas\Pawno 0.3b\filterscripts\Jail.pwn(103) : warning 217: loose indentation
Pawn compiler 3.2.3664              Copyright © 1997-2006, ITB CompuPhase


4 Errors.
And the lines:

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)