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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn all cars (
/showthread.php?tid=67035)
Respawn all cars -
KnooL - 26.02.2009
I searched for a cmd to respawn all cars but they remove somebody inside it.
How to have that command without removing the driver ? (Car stays on their position with the one inside)
Re: Respawn all cars -
kobrasek - 26.02.2009
Код:
if(strcmp(cmdtext, "/resetcars", true) == 0){
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);
}
return 1;
}
tell after if work?
Re: Respawn all cars -
KnooL - 26.02.2009
Quote:
Originally Posted by kobrasek
Код:
if(strcmp(cmdtext, "/resetcars", true) == 0){
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);
}
return 1;
}
tell after if work?
|
Thanks it works!
Re: Respawn all cars -
kobrasek - 26.02.2009
=] have fun
Re: Respawn all cars -
KnooL - 26.02.2009
Quote:
Originally Posted by knool
Quote:
Originally Posted by kobrasek
Код:
if(strcmp(cmdtext, "/resetcars", true) == 0){
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);
}
return 1;
}
tell after if work?
|
Thanks it works!
|
well the code is now:
Код:
if(strcmp(cmdtext, "/resetcars", true) == 0){
new p[MAX_VEHICLES];
new vh=CreateVehicle(400,0.0,0.0,0.0,0.0,-1,-1,-1);
DestroyVehicle(vh);
for(new v = 0; v < vh; v++){
p[v]=0;
for(new i = 0; i < GetMaxPlayers(); i++){
if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 3)
if(IsPlayerInVehicle(i,v)) p[v]=1;
}
if(p[v]==0) SetVehicleToRespawn(v);
}
return 1;
}
still it is working as non admin. what now?
Re: Respawn all cars -
KnooL - 26.02.2009
someone?
Re: Respawn all cars -
Coicatak - 26.02.2009
pawn Код:
#define MAX_CARS 700 //change to your car ammount
if(strcmp(cmd, "/respawncars", true) == 0)
{
if(IsPlayerAdmin(playerid)) //for rcon admin
{
for(new i=0; i<MAX_CARS; i++)
{
for(new pl = 0; pl<MAX_PLAYERS; pl++)
{
if(IsPlayerConnected(pl))
{
if(!IsPlayerInVehicle(pl, i) {SetVehicleToRespawn(i); return 0;}
}
}
}
}
else SendClientMessage(playerid, color, "You're not an admin"); //change color to your color code
return 1;
}
Re: Respawn all cars -
kobrasek - 26.02.2009
Код:
if(strcmp(cmdtext, "/resetcars", true) == 0){
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that 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);
}
return 1;
}
its work i ty it!... have fun =]
Re: Respawn all cars -
beckzy - 26.02.2009
Quote:
Код:
new vh=CreateVehicle(400,0.0,0.0,0.0,0.0,-1,-1,-1);
DestroyVehicle(vh);
|
That isn't necessarily going to give you the biggest vehicle id. Maybe there could be empty slots like where vehicles have been destroyed?
Re: Respawn all cars -
Coicatak - 27.02.2009
Use mine, it will respawn every cars as long as they're empty, and only rcon admins can use it. This command is smoothier that the one you use
Quote:
Originally Posted by Coicatak
pawn Код:
#define MAX_CARS 700 //change to your car ammount if(strcmp(cmd, "/respawncars", true) == 0) { if(IsPlayerAdmin(playerid)) //for rcon admin { for(new i=0; i<MAX_CARS; i++) { for(new pl = 0; pl<MAX_PLAYERS; pl++) { if(IsPlayerConnected(pl)) { if(!IsPlayerInVehicle(pl, i) {SetVehicleToRespawn(i); return 0;} } } } } else SendClientMessage(playerid, color, "You're not an admin"); //change color to your color code return 1; }
|