dcmd not work
#1

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;
}
Reply
#2

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

Try %i - If its a float, use %f
Reply
#4

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

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
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)