08.05.2013, 10:02
Sorry for the delayed reply, didn't have anybody to test.
And nope, it's not working - when an admin enters vehicle, nothing happens, though I want it to stop spectating.
I was able to create a public function IsAdminInVehicle and therefore to successfully create check if an admin is in vehicle when you try to start spectating it:
But I still can't get to figure out how to put player out of spectating when admin is entering already spectated vehicle.
And nope, it's not working - when an admin enters vehicle, nothing happens, though I want it to stop spectating.
I was able to create a public function IsAdminInVehicle and therefore to successfully create check if an admin is in vehicle when you try to start spectating it:
pawn Код:
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(IsAdminInVehicle(specvehicleid))
{
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);
}
But I still can't get to figure out how to put player out of spectating when admin is entering already spectated vehicle.