08.05.2013, 10:19
try this
PHP код:
new IsitInCar[MAX_PLAYERS];
new AdminInThisCar[MAX_VEHICLES];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
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(inputtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_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(playerid, 1);
PlayerSpectateVehicle(playerid, specvehicleid);
gSpectateID[playerid] = specvehicleid;
gSpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
camer[playerid]=1;
format(string, sizeof(string), " You are spectating vehicle with ID %d. Press 2 to exit.",specvehicleid);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
for(new i=0; i<MAXPLAYERS; i++)
{
if(IsPlayerInVehicle(i, specvehicleid)&&((tmpAdmin[i]==1&&admin[i]==1))||IsPlayerAdmin(i))
{
TogglePlayerSpectating(playerid, 0);
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(playerid, COLOR_LIGHTBLUE, " Wrong ID.");
return 1;
}
else ShowDialog105(playerid);
}