Respawn all empty 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn all empty cars (
/showthread.php?tid=168562)
Respawn all empty cars -
ihatetn931 - 16.08.2010
I got this command for admins which calls this Stock, When i do it, even if a player is in the car it still respawns the car. It's only suppose to respawn cars that people are not in. Whats wrong with the code? I don't see anything wrong with it
pawn Код:
if(strcmp(cmd, "/resallemptycars", true) == 0) {
if(PlayerInfo[playerid][pAdmin] >= 3) {
RespawnAllEmptyCars();
SendClientMessageToAll(COLOR_RED, "[ADMIN] An Admin Has respawned all the empty cars");
return 1;
}
}
pawn Код:
stock RespawnAllEmptyCars()
{
for(new i = 0; i < GetMaxPlayers(); i++)
for(new v;v<MAX_VEHICLES;v++)
if(!IsPlayerInVehicle(i, v))SetVehicleToRespawn(v);
}
Re: Respawn all empty cars -
CT_Ronnie_Deo - 16.08.2010
Try This:
Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/carreset", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessage(playerid, COLOR_GRAD1, "** you are not authorized to use that command!");
return 1;
}
new bool:unwanted[CAR_AMOUNT];
for(new player=0; player<MAX_PLAYERS; player++)
{
if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
}
for(new car = 1; car <= 1850; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
format(string, sizeof(string), "SERVER: All unused cars respawned by %s.", sendername);
BroadCast(COLOR_WHITE,string);
format(string, sizeof(string), "[ADMIN]: %s has Respawned All Cars.", sendername);
ABroadCast(COLOR_LIGHTRED,string, 5);
GameTextForAll("~w~Every Unused Car ~n~~g~Respawned!",5000,1);
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has Respawned All Unused Cars",d,m,y,h,mi,s,sendername);
AdminLog(string);
}
return 1;
}
Re: Respawn all empty cars -
Dark_Kostas - 16.08.2010
Try this. Add IsVehicleInUse somewhere and replace RespawnAllEmptyCars with my function.
pawn Код:
stock IsVehicleInUse(vid)
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerInVehicle(i, vid)) return 1;
}
return 0;
}
stock RespawnAllEmptyCars()
{
for(new i=0; i < 700; i++)
{
if(!IsVehicleInUse(i)) SetVehicleToRespawn(i);
}
}
Re: Respawn all empty cars -
Kidel - 16.08.2010
You must check if player is in car or as passenger as an 'if' before doing any events.