Respawning Vehs - 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: Respawning Vehs (
/showthread.php?tid=597110)
Respawning Vehs -
zamaleksc - 26.12.2015
So I use this to respawn vehicles
Код:
dcmd_respawnvehs(playerid,params[])
{
#pragma unused params
#pragma unused playerid
for(new i=0;i<MAX_VEHICLES;i++)
{
if(!VehicleOccupied(i))
{
SetVehicleToRespawn(i);
}
}
SendClientMessageToAll(COLOR_ADMIN, "Administrator has respawned all unoccupied vehicles.");
return 1;
}
and I use a command to spawn cars
Код:
PlayerInfo[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX+5, pY, pZ+2.0, pAngle, ColorOne, ColorTwo, -1)
I want when I use /respawnvehs to respawn unoccupied vehicles + Destroy those spawned ones,Any Ideas ?
Re: Respawning Vehs -
zPain - 26.12.2015
PHP код:
native IsValidVehicle(vehicleid);
// Inside the function
for(new p = GetPlayerPoolSize(); p > -1; --p) {
if(IsPlayerConnected(p)) {
if(IsValidVehicle(PlayerInfo[p][pSpawnVehicle])) {
DestroyVehicle(PlayerInfo[p][pSpawnVehicle]);
}
}
}
Re: Respawning Vehs -
zamaleksc - 26.12.2015
1)can you explain to me why you wrote IsPlayerConnected ?
2)What if a player is riding this spawned one?like i want to make it destroy those vehs if not occupied
Re: Respawning Vehs -
zPain - 26.12.2015
1. If I'm looping through the players, it's good sense that I check if the current id is connected.
2. I may have misinterpreted what you said. I thought you wanted to destroy the spawned vehicles even if they're occupied.
PHP код:
for(new p = GetPlayerPoolSize(); p > -1; --p) {
if(IsPlayerConnected(p)) {
if(IsValidVehicle(PlayerInfo[p][pSpawnVehicle])) {
if(!VehicleOccupied(PlayerInfo[p][pSpawnVehicle])) {
DestroyVehicle(PlayerInfo[p][pSpawnVehicle]);
}
}
}
}
Re: Respawning Vehs -
zamaleksc - 26.12.2015
So IsPlayerConnected means the player who spawned the vehicle or what it means ? sorry for my dumbness
EDIT:This didn't help and didn't destroy Spawned Vehicles.