Don't spectate vehicle when admin enters it
#4

try this

PHP код:

new IsitInCar[MAX_PLAYERS];
new 
AdminInThisCar[MAX_VEHICLES];
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        
IsitInCar[playerid] = GetPlayerVehicleID(playerid;
        if(
ifplayerdmin)AdminInThisCar[GetPlayerVehicleID(playerid)] = 1;
    }
    if(
oldstate == PLAYER_STATE_DRIVER)
    {
        if(
AdminInThisCar[IsitInCar[playerid]] == 1)AdminInThisCar[GetPlayerVehicleID(playerid)] = 0;
        
IsitInCar[playerid] = 0;
    }
    return 
1;
}
if(
dialogid==105_2)//Spectating vehicle
    
{
        if(
response)
        {
            new 
tmp[255];
            
tmp strtOK(inputtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_LIGHTBLUE" You didn't enter vehicle ID.");
                return 
1;
            }
            
specvehicleid strval(tmp);
            if(
AdminInThisCar[specvehicleid] == 1)
            {
                 
SendClientMessage(playerid,COLOR_RED," You are not allowed to spectate this vehicle, since an admin is sitting in it.");
                 return 
1;
            }
            if(
GetPlayerVehicleID(playerid)==specvehicleid)
            {
                
SendClientMessage(playerid,COLOR_RED," You cannot spectate vehicle you are sitting in.");
                return 
1;
            }
            if(
specvehicleid MAX_VEHICLES)
            {
                
TogglePlayerSpectating(playerid1);
                
PlayerSpectateVehicle(playeridspecvehicleid);
                
gSpectateID[playerid] = specvehicleid;
                
gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                
camer[playerid]=1;
                
format(stringsizeof(string), " You are spectating vehicle with ID %d. Press 2 to exit.",specvehicleid);
                
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
                for(new 
i=0i<MAXPLAYERSi++)
                {
                    if(
IsPlayerInVehicle(ispecvehicleid)&&((tmpAdmin[i]==1&&admin[i]==1))||IsPlayerAdmin(i))
                    {
                        
TogglePlayerSpectating(playerid0);
                        
gSpectateID[playerid] = INVALID_PLAYER_ID;
                        
gSpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                        
SetPlayerVirtualWorld(playerid,0);
                        
camer[playerid]=0;
                        
ShowDialog(playerid,43,DIALOG_STYLE_MSGBOX,"Info","{FCAC00}Another administrator has entered the vehicle you're spectating,\nso spectating is stopped.","OK","");
                        return 
1;
                    }
                }
            }
            else 
SendClientMessage(playeridCOLOR_LIGHTBLUE" Wrong ID.");
            return 
1;
        }
        else 
ShowDialog105(playerid);
    } 
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)