Respawning all cars problem - 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 all cars problem (
/showthread.php?tid=380279)
Respawning all cars problem -
trapstar2020 - 24.09.2012
CMD:respawnallcars(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
for(new v = 0; v < MAX_VEHICLES; v++)
{
SetVehicleToRespawn(v);
}
return 1;
}
I want if a player iz in the vehicle the car doesnt respawn any help?
Re: Respawning all cars problem -
Admigo - 24.09.2012
Here u go:
pawn Код:
CMD:respawnallcars(playerid,params[])
{
if(PlayerInfo[playerid][Level] <= 2)
{
new
i,
bool: vUsed[MAX_VEHICLES + 1];
foreachex(Player, i)
{
vUsed[GetPlayerVehicleID(i)] = true;
}
for(i = 1; i <= MAX_VEHICLES; ++i) {
if(!vUsed[i]) {
SetVehicleToRespawn(i);
}
}
return true;
}
else
{
SendClientMessage(playerid,COLOR_GREY,"You are not authorized to use this command.");
return 1;
}
}
Rep if i helped you
Re: Respawning all cars problem -
Beljulji - 24.09.2012
use this i use it and is the best

respawns only unused vehicles
Код:
if(strcmp(cmdtext, "/respawncars", true) == 0){
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can't use this command.");
new vh=CreateVehicle(400,0.0,0.0,0.0,0.0,-1,-1,-1);
DestroyVehicle(vh);
new p[MAX_VEHICLES];
for(new v = 0; v < vh; v++){
p[v]=0;
for(new i = 0; i < GetMaxPlayers(); i++){
if(IsPlayerInVehicle(i,v)) p[v]=1;
}
if(p[v]==0) SetVehicleToRespawn(v);
}
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Admin %s Has Respawned all Unused Cars!",pName);
SendClientMessageToAll(lightgreen,string);
return 1;
}
rep if this helped you