SA-MP Forums Archive
dcmd not work - 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: dcmd not work (/showthread.php?tid=195698)



dcmd not work - whitedragon - 03.12.2010

I'm making spec command but i don't debug the code....
Debug 1 shows what i enter but
Spec[playerid] shows me chars...
code for help..

pawn Код:
new Spec[MAX_PLAYERS];
new specs[MAX_PLAYERS];
dcmd_spec(playerid,params[])
{
    new t;
    if(PI[playerid][Admin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not Admin:)!");
    if(sscanf(params, "s",t)) return SendClientMessage(playerid, COLOR_GREY, "/spec [id]");
    else
    {
        new t2[128];
        format(t2,sizeof(t2),"%s",t);
        if(strlen(t2)> 0)
        {
            if(strcmp("off", t2, true))
            {
                Spec[playerid] = (-1);
            }
            else
            {
                Spec[playerid] = t;
            }
        }
        print(t2); // for debug
        print(Spec[playerid]); // for debug
        if(Spec[playerid] != (-1))
        {
            new vehicle2;
            vehicle2 = GetPlayerVehicleID(t);
            if(vehicle2 == 0)
            {
                TogglePlayerSpectating(playerid, 1);
                PlayerSpectatePlayer(playerid, t);
                specs[playerid] = 1;
            }
            else
            {
                TogglePlayerSpectating(playerid, 1);
                PlayerSpectateVehicle(playerid, vehicle2);
                specs[playerid] = 1;
            }
        }
        else
        {
            TogglePlayerSpectating(playerid, 0);
            PlayerSpectatePlayer(playerid, playerid);
            specs[playerid] = 0;
        }
    }
    return 1;
}



Re: dcmd not work - whitedragon - 03.12.2010

I know but if i use %d it show 0 when i type /spec off


Re: dcmd not work - Ash. - 03.12.2010

Try %i - If its a float, use %f


Re: dcmd not work - whitedragon - 03.12.2010

how many times i have to say? %i set when i use /spec off, off to 0


Re: dcmd not work - whitedragon - 03.12.2010

now found bug but how to fix it?
pawn Код:
if(strcmp("off", t2, true))
        {
            Spec[playerid] = (-1);
        }
        else
        {
            Spec[playerid] = t; //set wrong value:S
        }
but i don't have clue how to fix


Re: dcmd not work - dice7 - 03.12.2010

pawn Код:
if(sscanf(params, "d",t)) return SendClientMessage(playerid, COLOR_GREY, "/spec [id]");
Since d is for integer values in sscanf