Respawn all cars - 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: Respawn all cars (
/showthread.php?tid=300414)
Respawn all cars -
wumpyc - 30.11.2011
Hey Does anyone knows how to make that it respawns all empty vehicles...also
NOT-ATTACHED trailers...Cus current code respawns trailer if you have it attached or not..
pawn Код:
CMD:respawnallcars(playerid,params[])
{
new sendername[30],string[60];
if(APlayerData[playerid][PlayerLevel] < 3) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!");
for(new car = 1; car <= 268; car++)
{
if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
}
GetPlayerName(playerid,sendername,sizeof(sendername));
format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
SendClientMessageToAll(0xFFFFFFFF,string);
return 1;
}
stock IsVehicleEmpty(vehicleid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i, vehicleid)) return 0;
}
return 1;
}
Re: Respawn all cars -
Kingunit - 30.11.2011
Why are you looping twice? You are looping in the stock and in the command. Just one is enough I guess ...
Re: Respawn all cars -
wumpyc - 30.11.2011
Still need help! Trailer IDs are :435,450, 584,591.
Re: Respawn all cars -
[MG]Dimi - 30.11.2011
pawn Код:
CMD:respawnallcars(playerid,params[])
{
new sendername[30],string[60];
//if(APlayerData[playerid][PlayerLevel] < 3) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!");
for(new car = 0; car <= 268; car++)
if((IsVehicleEmpty(car) && !IsTrailerAttachedToVehicle(car) && car !=435 && car !=450 && car !=584 && car !=591) || (IsVehicleEmpty(car) && IsTrailerAttachedToVehicle(car) !=GetVehicleTrailer(car)))
{
SetVehicleToRespawn(car);
}
GetPlayerName(playerid,sendername,sizeof(sendername));
format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
SendClientMessageToAll(0xFFFFFFFF,string);
return 1;
}
Maybe like this?
Re: Respawn all cars -
wumpyc - 30.11.2011
Help me please ˘˘
Re: Respawn all cars -
[MG]Dimi - 30.11.2011
^Up^
Worked?
Re: Respawn all cars -
wumpyc - 30.11.2011
Quote:
Originally Posted by [MG]Dimi
pawn Код:
CMD:respawnallcars(playerid,params[]) { new sendername[30],string[60]; //if(APlayerData[playerid][PlayerLevel] < 3) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!"); for(new car = 0; car <= 268; car++) if((IsVehicleEmpty(car) && !IsTrailerAttachedToVehicle(car) && car !=435 && car !=450 && car !=584 && car !=591) || (IsVehicleEmpty(car) && IsTrailerAttachedToVehicle(car) !=GetVehicleTrailer(car))) { SetVehicleToRespawn(car); } GetPlayerName(playerid,sendername,sizeof(sendername)); format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername); SendClientMessageToAll(0xFFFFFFFF,string); return 1; }
Maybe like this?
|
I attached it to my truck (trailer) and used CMD but it respawned trailer
Re: Respawn all cars -
wumpyc - 30.11.2011
I edited a little but still respawns trailer if is attached to my truck or isn't...
pawn Код:
CMD:respawnallcars(playerid,params[])
{
new sendername[30],string[60];
//if(APlayerData[playerid][PlayerLevel] < 3) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!");
for(new car = 0; car <= 268; car++)
if(IsVehicleEmpty(car) && IsTrailerAttachedToVehicle(car) || IsVehicleEmpty(car))
{
SetVehicleToRespawn(car);
}
GetPlayerName(playerid,sendername,sizeof(sendername));
format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
SendClientMessageToAll(0xFFFFFFFF,string);
return 1;
}
stock IsVehicleEmpty(vehicleid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i, vehicleid)) return 0;
}
return 1;
}
Re: Respawn all cars -
Rafiko - 30.11.2011
pls help guys pls
having the same issues....
tnx in advance
Re: Respawn all cars -
wumpyc - 30.11.2011
Still need help ˇˇ