Help with VehSync! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with VehSync! (
/showthread.php?tid=284695)
Help with VehSync! -
Moron - 20.09.2011
Okay, I have a vehicle sync script in my gamemode, but I have a problem. If I make a vehicle with a respawn timer and use it after it respawns vehicle sync starts to work and brings back the vehicle to the position were I left the vehicle after done using it ;/ I could remove one of those things, but unfortunately I need them both. Does anyone have any ideas?
I tried to do one thing, but after the vehicle respawned all the others disapear from the map
Well I tried to do so:
1. In:
Код:
if(!(vehicleDB[vehicleid][lastpos][0]==0 && vehicleDB[vehicleid][lastpos][1] == 0 && vehicleDB[vehicleid][lastpos][2] == 0))
{
SetVehiclePos(vehicleid,vehicleDB[vehicleid][lastpos][0],vehicleDB[vehicleid][lastpos][1],vehicleDB[vehicleid][lastpos][2]);
SetVehicleZAngle(vehicleid,vehicleDB[vehicleid][lastpos][3]);
I added
Код:
vehicleDB[vehicleid][sync]==1 &&
And got:
Код:
forward SyncVehis();
public SyncVehis()
{
new bool:dontsync[500];
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
{
new vehicleid=GetPlayerVehicleID(playerid);
dontsync[vehicleid]=true;
GetVehiclePos(vehicleid,vehicleDB[vehicleid][lastpos][0],vehicleDB[vehicleid][lastpos][1],vehicleDB[vehicleid][lastpos][2]);
GetVehicleZAngle(vehicleid,vehicleDB[vehicleid][lastpos][3]);
}
}
for(new vehicleid=0; vehicleid<maxvehicles+1; vehicleid++)
{
if(!dontsync[vehicleid])
{
if(!(vehicleDB[vehicleid][sync]==1 && vehicleDB[vehicleid][lastpos][0]==0 && vehicleDB[vehicleid][lastpos][1] == 0 && vehicleDB[vehicleid][lastpos][2] == 0))
{
SetVehiclePos(vehicleid,vehicleDB[vehicleid][lastpos][0],vehicleDB[vehicleid][lastpos][1],vehicleDB[vehicleid][lastpos][2]);
SetVehicleZAngle(vehicleid,vehicleDB[vehicleid][lastpos][3]);
}
}
}
}
2. Then I made these things:
Код:
public NoSync(vehicleid)
{
vehicleDB[vehicleid][sync]=0;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
SetTimer("NoSync", 65000, false);
vehicleDB[vehicleid][sync]=1;