Respawn All Command.. - 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 Command.. (
/showthread.php?tid=218869)
Respawn All Command.. -
Antonio [G-RP] - 31.01.2011
Here is my command. I've no idea whats wrong with it, I've tried multiple times to fix it...
pawn Код:
CMD:respawnall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
for(new v=0; v<MAX_VEHICLES; v++)
{
if(!IsVehicleOccupied(v))
{
new string[128];
SetVehicleToRespawn(v);
format(string, 256, "[AdmCmd] %s has respawned all unoccupied vehicles", GetPlayerNameEx(playerid));
SendGlobalMessage(COLOR_ADMIN, string);
return 1;
}
}
}
else {
SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command.");
}
return 1;
}
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
new playerstate;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
playerstate = GetPlayerState(i);
if(playerstate == PLAYER_STATE_DRIVER || playerstate == PLAYER_STATE_PASSENGER)
{
if(IsPlayerInVehicle(i,vehicleid))
{
return 1;
}
}
}
}
return 0;
}
Re: Respawn All Command.. -
HyperZ - 31.01.2011
pawn Код:
CMD:respawnall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command.");
for(new v=0; v<MAX_VEHICLES; v++)
{
if(!IsVehicleOccupied(v))
{
new string[128];
SetVehicleToRespawn(v);
format(string, 256, "[AdmCmd] %s has respawned all unoccupied vehicles", GetPlayerNameEx(playerid));
SendGlobalMessage(COLOR_ADMIN, string);
}
}
return 1;
}
pawn Код:
forward IsVehicleOccupied(vehicleid);
public IsVehicleOccupied(vehicleid)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return 0;
}
Re: Respawn All Command.. -
Antonio [G-RP] - 31.01.2011
Was the problem that I was using a stock heading rather than public?
Re: Respawn All Command.. -
Antonio [G-RP] - 01.02.2011
Didn't work.
Re: Respawn All Command.. -
PeteShag - 01.02.2011
pawn Код:
CMD:respawnall(playerid, params[])
{
new string[128];
if(PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command.");
format(string, 256, "[AdmCmd] %s has respawned all unoccupied vehicles", GetPlayerNameEx(playerid));
SendGlobalMessage(COLOR_ADMIN, string);
for(new v=0; v<MAX_VEHICLES; v++)
{
if(!IsVehicleOccupied(v))
{
SetVehicleToRespawn(v);
//format(string, 256, "[AdmCmd] %s has respawned all unoccupied vehicles", GetPlayerNameEx(playerid));
//SendGlobalMessage(COLOR_ADMIN, string); This would spam you for evey vehicle
}
}
return 1;
}
I cant see anything wrong with your command and the IsVehicleOccupied that Clive posted, works pefrect. However I found something that would spam you.
Re: Respawn All Command.. -
Krx17 - 01.02.2011
Add print messages throughout the command and see which ones print and which do not. If one does not print, you know the code near it is the problem.