SA-MP Forums Archive
help with /spec command - 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: help with /spec command (/showthread.php?tid=223364)



help with /spec command - YungGee - 09.02.2011

My /spec is bugged and idk why i tried everything,

When the players on foot its ok but if there in a vehicle it bugs and specs id 0 regardless the id u put :S

pawn Код:
CMD:spec(playerid, params[])
{
    if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,RED,">> You Must Be Level 2+ To Use This Command!");
    new specid;
    new specvehicleid = GetPlayerVehicleID(specid);
    if(sscanf(params, "U", specid)) return SendClientMessage(playerid,RED, "USAGE: /spec [id]");
    {
        if (specid == INVALID_PLAYER_ID) return SendClientMessage(playerid,RED, ">> Player Not Found!");
        if(IsPlayerInAnyVehicle(specid))//If there in a vehicle do...
        {
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectateVehicle(playerid, specvehicleid);
            SendClientMessage(playerid,YELLOW,">> Spec On!, Use /specoff To Disable Spec!");
        }
        else //if on foot do...
        {
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, specid);
            SendClientMessage(playerid,YELLOW,">> Spec On!, Use /specoff To Disable Spec!");
        }
    }
    return true;
}
Any help :S

Also will it auto pick up if they enter a vehicle then auto spec vehicle?


Re: help with /spec command - Calgon - 09.02.2011

pawn Код:
CMD:spec(playerid, params[])
{
    if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,RED,">> You Must Be Level 2+ To Use This Command!");
    new specid;
    if(sscanf(params, "U", specid)) return SendClientMessage(playerid,RED, "USAGE: /spec [id]");
    {
        if (specid == INVALID_PLAYER_ID) return SendClientMessage(playerid,RED, ">> Player Not Found!");
        if(IsPlayerInAnyVehicle(specid))//If there in a vehicle do...
        {
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectateVehicle(playerid, GetPlayerVehicleID(specid));
            SendClientMessage(playerid,YELLOW,">> Spec On!, Use /specoff To Disable Spec!");
        }
        else //if on foot do...
        {
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectatePlayer(playerid, specid);
            SendClientMessage(playerid,YELLOW,">> Spec On!, Use /specoff To Disable Spec!");
        }
    }
    return true;
}
The problem was that you assigned the vehicle ID before you actually got a user ID from sscanf. You also created a variable you really didn't need as you can simply use the GetPlayerVehicleID function instead of creating a new variable to store the vehicle ID in which I removed and replaced with usage of the function.


Re: help with /spec command - YungGee - 09.02.2011

Ahh i see, Thankyou sir, Much appreciated.


Re: help with /spec command - duukjones - 09.02.2011

I had this problem too, solved now!