26.07.2013, 07:14
Sometimes when a player si driving his car, it removes him out ot the car and deletes the car?
Where is the problem?
Here are the sciprts
I use to car spawners - with a dialog and with a model preview menu
Thanks in advance!
Where is the problem?
Here are the sciprts
pawn Код:
public VehicleSpawner(playerid,model){
if(IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, COLOR_RED, "ГРЕШКА: Вече имаш кола!");
}
else{
if(VehicleSpawn[playerid]==0){
new Float:x,Float:y,Float:z,Float:a, vehicleid;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
vehicleid = CreateVehicle(model,x+1,y+1,z,a,-1,-1,-1);
PutPlayerInVehicle(playerid, vehicleid, 0);
SetVehicleHealth(vehicleid, 1000.0);
LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));
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 A=c+1;
PlayerVehicle[playerid][c]=PlayerVehicle[playerid][A];
}
PlayerVehicle[playerid][b]=0;
Turn[playerid]--;
}
if(!PlayerVehicle[playerid][i]){
PlayerVehicle[playerid][i]=vehicleid;
Turn[playerid]++;
break;
}
}
}
else{
new string[256];
format(string, sizeof(string), "Изчакай %d sec. преди да вземаш превозно средство пак!", VehicleSpawn[playerid]);
SendClientMessage(playerid,COLOR_RED, string);
}
}
}
public 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("VehicleReseter",2000,0,"i",vehicleid);
}
public VehicleReseter(vehicleid)
{
DestroyVehicle(vehicleid);
}
public VehicleSpawnerLimiter(){
new i;
for(i=0;i<=MAX_PLAYERS;i++){
if(VehicleSpawn[i]>0){
VehicleSpawn[i]--;
}
}
}
public OnVehicleSpawn(vehicleid)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
for(new u=0;u<MAX_PLAYERVEHICLES;u++)
{
if(vehicleid==PlayerVehicle[i][u])
{
VehicleDeleter(vehicleid);
PlayerVehicle[i][u]=0;
Turn[i]--;
}
}
}
return 0;
}
Thanks in advance!