Quote:
Originally Posted by White_116
Как-то так всё и решается.
PHP код:
new W_VehicleDriver[MAX_VEHICLES] = {-1, ...};
new W_PlayerDrive[MAX_PLAYERS] = {-1, ...};
public OnPlayerConnect(playerid)
{
W_PlayerDrive[playerid] = -1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(W_PlayerDrive[playerid] != -1)
{
if(W_VehicleDriver[W_PlayerDrive[playerid]] == playerid)
{
W_VehicleDriver[W_PlayerDrive[playerid]] = -1;
}
W_PlayerDrive[playerid] = -1;
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid > 0)
{
//if(GetVehicleModel(vehicleid) == 0) //WTF???
if(W_PlayerDrive[playerid] != -1)//WTF???
{
W_VehicleDriver[W_PlayerDrive[playerid]] = -1;
}
if(W_VehicleDriver[vehicleid] != playerid)
{
if(IsPlayerConnected(W_VehicleDriver[vehicleid]))
{
if(GetPlayerVehicleID(W_VehicleDriver[vehicleid]) == vehicleid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(W_VehicleDriver[vehicleid], x, y, z);
SetPlayerPos(W_VehicleDriver[vehicleid], x, y, z);
}
}
}
W_PlayerDrive[playerid] = vehicleid;
W_VehicleDriver[vehicleid] = playerid;
}
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
if(W_PlayerDrive[playerid] != -1)//WTF???
{
if(W_VehicleDriver[W_PlayerDrive[playerid]] == playerid)
{
W_VehicleDriver[W_PlayerDrive[playerid]] = -1;
}
W_PlayerDrive[playerid] = -1;
}
}
return 1;
}
public OnPlayerUpdate(playerid)
{
new bool:is_ok = true;
if(W_PlayerDrive[playerid] != -1)
{
if(W_VehicleDriver[W_PlayerDrive[playerid]] != playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z);
is_ok = false;
}
}
return is_ok;
}
P.S. Код не проверял. Нет возможности симулировать ситуацию.
|
Не помогло, проблема осталась