SA-MP Forums Archive
How to assign a value - 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: How to assign a value (/showthread.php?tid=175264)



How to assign a value[SOLVED] - zack3021 - 09.09.2010

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



Re: How to assign a value - iggy1 - 09.09.2010

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)


Re: How to assign a value - zack3021 - 09.09.2010

Lol now how to add it to the script?


Re: How to assign a value - ••• ĤБĶБM ••• - 09.09.2010

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.


Re: How to assign a value - zack3021 - 09.09.2010

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


Re: How to assign a value - Vince - 09.09.2010

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


Re: How to assign a value - i514x - 09.09.2010

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


Re: How to assign a value - zack3021 - 09.09.2010

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



Re: How to assign a value - i514x - 09.09.2010

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?


Re: How to assign a value - zack3021 - 09.09.2010

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: