Respawn 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 Empty Cars (
/showthread.php?tid=102099)
Respawn Empty Cars -
Beaver07 - 13.10.2009
Hey guys just having a problem with this code when i enter the command it does respawn the cars just it also returns SERVER :UNKOWN COMMAND any ideas?
Код:
if(strcmp(cmd, "/respawncars", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] == 0)
{
format(string,sizeof(string),"* The Command (%s) Is Unknown, Use '/help' For Commands.",cmdtext);
SendClientMessage(playerid,COLOR_WHITE, string);
return 1;
}
SendClientMessage(playerid,COLOR_WHITE,"* All Empty Cars Have Been Respawned");
RespawnEmptyCars();
return 1;
}
public RespawnEmptyCars()
{
for(new d = 0; d < MAX_VEHICLES; d++)
{
if(IsVehicleEmpty(d))
{
SetVehicleToRespawn(d);
VehicleInfo[d][gas] = 100;
ModVehicle(d);
}
}
}
IsVehicleEmpty(vehicleid)
{
for(new i = 0, j = GetMaxPlayers(); i < j; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && IsPlayerInVehicle(i,vehicleid)) return false;
}
return true;
}
Re: Respawn Empty Cars -
(.Aztec); - 13.10.2009
I'm just making a wild guess here, but try this:
pawn Код:
public RespawnEmptyCars()
{
for(new d = 0; d < MAX_VEHICLES; d++)
{
if(IsVehicleEmpty(d))
{
SetVehicleToRespawn(d);
VehicleInfo[d][gas] = 100;
ModVehicle(d);
}
}
return 1;
}
Re: Respawn Empty Cars -
woot - 13.10.2009
pawn Код:
public RespawnEmptyCars()
{
for(new i=0; i<MAX_VEHICLES; i++)
{
for(new pl = 0; pl<MAX_PLAYERS; pl++)
{
if(IsPlayerConnected(pl))
{
if(!IsPlayerInVehicle(pl, i))
{
SetVehicleToRespawn(i);
}
}
}
}
}
Re: Respawn Empty Cars -
Beaver07 - 13.10.2009
thanks for quick response just used
Quote:
Originally Posted by //exora
pawn Код:
public RespawnEmptyCars() { for(new i=0; i<MAX_VEHICLES; i++) { for(new pl = 0; pl<MAX_PLAYERS; pl++) { if(IsPlayerConnected(pl)) { if(!IsPlayerInVehicle(pl, i)) { SetVehicleToRespawn(i); } } } } }
|
saved me a few lines and a headache thanks
Re: Respawn Empty Cars -
tunetu - 13.10.2009
Or you can use...
pawn Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) // by TyreXel
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 1337)
{
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 <= 500; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), " All unused cars have been respawned by administrator %s.", sendername);
BroadCast(COLOR_WHITE,string);
}
return 1;
}
Re: Respawn Empty Cars -
(.Aztec); - 13.10.2009
Quote:
Originally Posted by tunetu
Or you can use...
pawn Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) // by TyreXel { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pAdmin] < 1337) { 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 <= 500; car++) { if(!unwanted[car]) SetVehicleToRespawn(car); } GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), " All unused cars have been respawned by administrator %s.", sendername); BroadCast(COLOR_WHITE,string); } return 1; }
|
Not necessarily, he's not looking for a command to do it, he was looking for someone to fix his public, which I failed at, and //exora did.