/spec in vehicle bug
#1

It works when I type /spec [id] while he/she is in a vehicle, but when the player leaves the vehicle, I keep specing the vehicle. Also when I'm specing someone on foot, and the player enters the car, I will see the inside of the car...

What is wrong?
pawn Код:
dcmd_spec(playerid, params[])
{
    new index = 0;
  tmp2 = strtok(params, index);
    if (pInfo[playerid][pAdmin] < 1)
    {
        SystemMessage(playerid, "You are not an Administrator with the required level.");
        return 1;
    }
  if(!strlen(tmp2))
    {
        SystemMessage(playerid, "[USAGE] ''/spec [playername/id]''.");
        return 1;
    }
    new string[MAX_STRING];
    new second, minute, hour, day, month, year;
    giveplayerid = ReturnUser(tmp2);
    if(IsPlayerConnected(giveplayerid))
    {
        TogglePlayerSpectating(playerid, 1);
        if(!IsPlayerInAnyVehicle(giveplayerid)) PlayerSpectatePlayer(playerid, giveplayerid);
    else PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid), SPECTATE_MODE_NORMAL);
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
        gSpectateID[playerid] = giveplayerid;
        gSpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
        gettime(hour, minute, second);
        getdate(year, month, day);
        format(string, sizeof(string), "Player %s started spectating player %s on %d/%d/%d at %d:%d:%d.", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second);
        ServerLog(string);
        printf(string);
    }
    else
  {
    format(string, sizeof(string), "That player is not active.");
    SystemMessage(playerid, string);
    }
    return 1;
}
Reply
#2

You'll have to perform checks, maybe using onvehicleenter or onvehicleexit, to keep updating the spec. (Hard Way) [But most efficent]

Otherwise, just re-use the command everytime the player changes the state of vehicle/onfoot etc. (Easy Way)
Reply
#3

When I try to re-script /spec it's 100 percent bugged...
Reply
#4

Look at every line of this tiny piece of script & try to understand what it all does, then create a new similar command using only what you learned/know & keep at it until you get it right or just don't understand a certain piece that might actually be important. Doing this will not only teach you how to script a simple spec command, but will in fact give you enough knowledge to create any simple command... I don't simply give the answers, I try to get you new scripters at learning the answer

Work at it for a while, if you can't figure something out, post it up here again if it can't be found via search
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)