17.07.2012, 08:30
pawn Код:
forward VehRes(vehicleid);
VehicleDeleter(vehicleid)
{
for(new i=0;i<MAX_PLAYERS;i++){
new Float:X,Float:Y,Float:Z;
if(IsPlayerInVehicle(i, vehicleid)){
RemovePlayerFromVehicle(i);
GetPlayerPos(i,X,Y,Z);
SetPlayerPos(i,X,Y+3,Z);
}
SetVehicleParamsForPlayer(vehicleid,i,0,1);
}
SetTimerEx("VehRes", 60000, 0, "d", vehicleid);
}
public VehRes(vehicleid) return DestroyVehicle(vehicleid);
VehicleSpawner(playerid,model)
{
if(VehicleSpawn[playerid]==0)
{
new vehicleid;
new Float:x, Float:y, Float:z, Float:a;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
else
{
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
}
vehicleid = CreateVehicle(model, x, y, z, a, -1, -1, -1);
SetVehiclePos(vehicleid, x, y, z);
SetVehicleZAngle(vehicleid, a);
SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, vehicleid, 0);
SetVehicleHealth(vehicleid, 1000.0);
for(new i=0;i<MAX_PLAYERVEHICLES;i++)
{
if(Turn[playerid] == MAX_PLAYERVEHICLES)
{
VehicleDeleter(PlayerVehicle[playerid][0]);
new b = MAX_PLAYERVEHICLES - 1;
for(new c=0; c<b; c++)
{
new Aa=c+1;
PlayerVehicle[playerid][c]=PlayerVehicle[playerid][Aa];
}
PlayerVehicle[playerid][b] = 0;
Turn[playerid]--;
}
if(!PlayerVehicle[playerid][i])
{
PlayerVehicle[playerid][i] = vehicleid;
Turn[playerid]++;
break;
}
}
}
}