public OnPlayerStateChange(playerid, newstate, oldstate)
{
if( oldstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_DRIVER)
{
if(IsAdminv(GetPlayerVehicleID(playerid)))
{
if(PlayerInfo[playerid][Admin] < 1)
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
DestroyVehicle(vehicleid);
SendClientMessage(playerid, 0xFF0000FF, ""RED"ERROR:"GREY" Unauthorized Vehicle");
}
}
}
return 1;
}
stock IsAdminv(vehicleid)
{
new result;
new model = GetVehicleModel(vehicleid);
switch(model)
{
case 425, 432, 447, 430, 449, 476, 520, 537, 538, 569, 570, 577, 590, 592, 610: result = model;
default: result = 0;
}
return result;
}
Well, you could use OnPlayerEnterVehicle.
This'll make stuff alot easier instead of checking for player states. |
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) // Edited
{
if(IsAdminv(GetPlayerVehicleID(playerid)))
{
if(PlayerInfo[playerid][Admin] < 1)
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
DestroyVehicle(vehicleid);
SendClientMessage(playerid, 0xFF0000FF, ""RED"ERROR:"GREY" Unauthorized Vehicle");
}
return 1; // Added
}
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if( oldstate == PLAYER_STATE_ONFOOT || newstate == PLAYER_STATE_DRIVER)
{
if(IsAdminv(GetPlayerVehicleID(playerid)))
{
if(PlayerInfo[playerid][Admin] < 1)
{
new vehicleid;
vehicleid= GetPlayerVehicleID(playerid);
DestroyVehicle(vehicleid);
SendClientMessage(playerid, 0xFF0000FF, ""RED"ERROR:"GREY" Unauthorized Vehicle");
}
}
}
return 1;
}
pawn Код:
|
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
this code is deleting the vehicles when they enter in them or spawn them on foot but when they spawn these vehicles while in a vehicle then the script isnt deleting the vehicle
|
What basically you're checking is..
IF PLAYER WAS IN A VEHICLE.. >>>> Then he got TPed into another one. >>>> Delete 2nd vehicle. |
static CurrVehicleID[MAX_PLAYERS];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(IsAdminv(CurrVehicleID[playerid]))
{
if(PlayerInfo[playerid][Admin] < 1)
{
if(oldstate == PLAYER_STATE_DRIVER) DestroyVehicle(CurrVehicleID[playerid]);
SendClientMessage(playerid, 0xFF0000FF, ""RED"ERROR:"GREY" Unauthorized Vehicle");
}
}
CurrVehicleID[playerid] = GetPlayerVehicleID(playerid);
}
return 1;
}