help with /spec command
#2

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.
Reply


Messages In This Thread
help with /spec command - by YungGee - 09.02.2011, 12:25
Re: help with /spec command - by Calgon - 09.02.2011, 12:30
Re: help with /spec command - by YungGee - 09.02.2011, 12:48
Re: help with /spec command - by duukjones - 09.02.2011, 14:43

Forum Jump:


Users browsing this thread: 1 Guest(s)