SA-MP Forums Archive
Commands can only be used on ID's 0 and 1 - 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)
+--- Thread: Commands can only be used on ID's 0 and 1 (/showthread.php?tid=372318)



Commands can only be used on ID's 0 and 1 - HydraX - 26.08.2012

Hello. It's 3am and I'm still having trouble fixing this problem I've been having.
As the title says, my commands mostly use parameters. Mostly player parameters.
However only certain ID's can make these commands work, ID 0 and 1, after selecting 2 and above..it doesn't work and returns as ID 0.

pawn Код:
YCMD:jail(playerid, params[], help)
{
    if( help ) return SendClientMessage( playerid, -1, "SERVER: Jail a player" );
    if( PlayerInfo[playerid][pAdmin] >= 1 )
    {
        new
            TargetID,
            tReason[50];
        if( !sscanf(params, "uS(No reason specified)[50]", TargetID, tReason) )
        {
            if( strlen( tReason) > 50 )                     return SendClientMessage( playerid, -1, "SERVER: Maximum reason size: 50" );
            if( !IsPlayerConnected(TargetID))           return SendClientMessage( playerid, -1, "SERVER: Invalid playerid! Please try again" );
            new
                MyString[128],
                TargetString[128],
                Float:Pos[3];
            PlayerInfo[TargetID][pJailed] = true;
            GetPlayerPos( TargetID, Pos[0], Pos[1], Pos[2] );
            new rand = random(sizeof(JailCellSpawns));
            SetPlayerPos(TargetID, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
            format( MyString, sizeof MyString, "SERVER: Jailed %s (ID: %i). Reason: %s", GetName(TargetID), TargetID, tReason );
            format( TargetString, sizeof TargetString, "SERVER: %s (ID: %i) was jailed by %s (ID: %i). Reason: %s", GetName(TargetID), TargetID, GetName(playerid), playerid, tReason );
            SendClientMessage( playerid, -1, MyString );
            SendClientMessageToAll( -1, TargetString );
        }
        else
            return SendClientMessage( playerid, -1, "SERVER: /jail <TargetID> <Reason>" );
    }
    else
        return SendClientMessage( playerid, -1, "SERVER: You have to be an admin to perform this command!" );
    return 1;
}
pawn Код:
stock GetName(playerid)
{
    new
        pName[24];
    GetPlayerName( playerid, pName, sizeof pName );
    return pName;
}



Re: Commands can only be used on ID's 0 and 1 - Johnson_Brooks - 26.08.2012

are u doing /jail dirtykiller ? or /jail 4 ?
Because from your code,you cant do /jail dirtykiller,it will /jail id 0.


Re: Commands can only be used on ID's 0 and 1 - Akira297 - 26.08.2012

<I'ma let Brook do this one>


Respuesta: Commands can only be used on ID's 0 and 1 - HydraX - 26.08.2012

I know that ID's can only be used. That isn't my problem, My problem is that any ID's above 1, will result in ID 0 being called.


Re: Commands can only be used on ID's 0 and 1 - leonardo1434 - 26.08.2012

Give a try.

pawn Код:
YCMD:jail(playerid, params[],help)
{
    if( help ) return SendClientMessage( playerid, -1, "SERVER: Jail a player" );
    if( PlayerInfo[playerid][pAdmin] < 1 ) return SendClientMessage( playerid, -1, "SERVER: You have to be an admin to perform this command!" );
    new
        TargetID,
        tReason[50];
    if( sscanf(params, "uS[50]", TargetID, tReason) ) return SendClientMessage( playerid, -1, "SERVER: /jail <TargetID> <Reason>" );
    if( tReason[0] == '\0' || !!tReason[49]) return SendClientMessage( playerid, -1, "SERVER: Maximum reason size: 1 - 50" );
    if( !IsPlayerConnected(TargetID)) return SendClientMessage( playerid, -1, "SERVER: Invalid playerid! Please try again" );
    new
        MyString[128];
    PlayerInfo[TargetID][pJailed] = true;
    new rand = random(sizeof(JailCellSpawns));
    SetPlayerPos(TargetID, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
    format( MyString, sizeof MyString, "SERVER: Jailed %s (ID: %i). Reason: %s", GetName(TargetID), TargetID, tReason );
    SendClientMessage( playerid, -1, MyString );
    format( MyString, sizeof MyString, "SERVER: %s (ID: %i) was jailed by %s (ID: %i). Reason: %s", GetName(TargetID), TargetID, GetName(playerid), playerid, tReason );
    SendClientMessageToAll( -1, MyString );
    return 1;
}



Respuesta: Commands can only be used on ID's 0 and 1 - HydraX - 26.08.2012




Re: Commands can only be used on ID's 0 and 1 - leonardo1434 - 26.08.2012

Put that after set the TargetID Pos's. most probably it will printf 0.
pawn Код:
printf(#X - %f - Y - %f - Z - %f,JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);



Respuesta: Commands can only be used on ID's 0 and 1 - HydraX - 26.08.2012

Код:
sscanf warning: No default value found.
sscanf warning: String buffer overflow.
X - 220.068405 - Y - -1839.234863 - Z - 16.437999
sscanf warning: No default value found.
sscanf warning: Unknown format specifier '[', skipping.
sscanf warning: Unknown format specifier '5', skipping.
sscanf warning: Unknown format specifier '0', skipping.
sscanf warning: Unknown format specifier ']', skipping.
sscanf warning: Format specifier does not match parameter count.
sscanf warning: No default value found.
X - 209.082305 - Y - -1840.103637 - Z - 11.804499



Re: Commands can only be used on ID's 0 and 1 - leonardo1434 - 26.08.2012

change the "S[50]" to "s[50]", most probably is case sensitive.


Respuesta: Re: Commands can only be used on ID's 0 and 1 - HydraX - 26.08.2012

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
change the "S[50]" to "s[50]", most probably is case sensitive.
No, I just needed to add a "(N/A)" incase the player didn't type a reason.

Still doesn't solve the problem though.