/spec in a vehicle bug
#1

When I type /spec [playername/id] and the one I want to spec is in a vehicle, I will see him/her INSIDE the vehicle, it looks very weird. Just like cam hack, but the original SA. And I want the normal one. This is my command:

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);
        PlayerSpectatePlayer(playerid, giveplayerid);
        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

this spectates a player on foot:
Код:
PlayerSpectatePlayer(playerid,observedplayerid);
..and this will spectate the player in a vehicle;
Код:
PlayerSpectateVehicle(playerid,vehicleid,SPECTATE_MODE_NORMAL);
Reply
#3

Quote:
Originally Posted by Babul
this spectates a player on foot:
Код:
PlayerSpectatePlayer(playerid,observedplayerid);
..and this will spectate the player in a vehicle;
Код:
PlayerSpectateVehicle(playerid,vehicleid,SPECTATE_MODE_NORMAL);
Not working.
Reply
#4

PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid), SPECTATE_MODE_NORMAL);
Reply
#5

I'm not 100% sure what spectating system you're using, but I have seen it before. If I remember right, there are 3 different spectating modes, so the code should be like this. Am I right?

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);
        PlayerSpectatePlayer(playerid, giveplayerid);
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
        gSpectateID[playerid] = giveplayerid;
        gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
        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
#6

Quote:
Originally Posted by Carlton
I'm not 100% sure what spectating system you're using, but I have seen it before. If I remember right, there are 3 different spectating modes, so the code should be like this. Am I right?

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);
        PlayerSpectatePlayer(playerid, giveplayerid);
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
        gSpectateID[playerid] = giveplayerid;
        gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
        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;
}
Not working people! It looks like this:

Reply
#7

Hmm, try this code.

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))
    {
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
        gSpectateID[playerid] = giveplayerid;
        gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
          TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, giveplayerid);
        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
#8

Quote:
Originally Posted by Carlton
Hmm, try this code.

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))
    {
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
        gSpectateID[playerid] = giveplayerid;
        gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
         TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, giveplayerid);
        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;
}
No, ain't working. You see, I don't see the problem, just like other people.
Reply
#9

Quote:
Originally Posted by Seif_
No, you need to use PlayerSpectateVehicle if giveplayerid is inside a vehicle. You need to spectate his vehicle.
I have no experience with this. Could someone fix this command? So I can look and learn for the next time:

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);
        PlayerSpectatePlayer(playerid, giveplayerid);
        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;
}
This is the bug:

Spectating inside a car.
Reply
#10

It is easy.

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;
}
And add some code under OnPlayerStateChange...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)