Respawn Vehicle - Admin Level - Please help - 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: Respawn Vehicle - Admin Level - Please help (
/showthread.php?tid=511593)
Respawn Vehicle - Admin Level - Please help -
Miladajir - 06.05.2014
hello
i have problem.
my admin level 3. but not use command.
Код:
CMD:rv(playerid,params[])
{
if(PInfo[playerid][Level] >= 3)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(!IsPlayerInAnyVehicle(x))
{
SetVehicleToRespawn(i);
}
}
}
SendClientMessageToAll(0xFFFFFFFF,"{FF0000}Administrator Respawn Vehicle!!!");
SendClientMessage(playerid,0xFFFFFFFF,"{FF9900}You Respawn Vehicle!!!!");
}
else
{
SendClientMessage(playerid,-4,"{FF9900}Only Admin Level 3 To Use Command!!!");
}
return 1;
}
When the admin wants to use the rv command.
Text: Only Admin Level 3 To Use Command!!!
Please Help.
------------------------
sorry. my bad english
Re: Respawn Vehicle - Admin Level - Please help -
Nathan_Taylor - 06.05.2014
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
for(new i =0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInVehicle(i,vehicleid))
{
return 1;
}
}
return 0;
}
CMD:rv(playerid,params[])
{
if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,-4,"{FF9900}Only Admin Level 3 To Use Command!!!");
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(!IsVehicleOccupied(i))
{
SetVehicleToRespawn(GetPlayerVehicleID(i));
}
}
SendClientMessageToAll(0xFFFFFFFF,"{FF0000}Administrator Respawn Vehicle!!!");
SendClientMessage(playerid,0xFFFFFFFF,"{FF9900}You Respawn Vehicle!!!!");
return 1;
}
EDIT 2: My bad, thought you were trying to respawn them if someone was in them, I'll change the code above. UPDATED
Try that code. It will work if the admin level is 3 or above, and will only respawn unoccupied vehicles.
Re: Respawn Vehicle - Admin Level - Please help -
KillerStrike23 - 06.05.2014
PHP код:
if(PInfo[playerid][Level] <= 3)

if I helped rep me
Re: Respawn Vehicle - Admin Level - Please help -
Konstantinos - 06.05.2014
It's obvious the admin level for that player is not 3 or greater.
By the way your code is really bad. If a vehicle is not occupied, it will keep respawning as many times as the MAX_PLAYERS is.
pawn Код:
// in the command:
for(new v = 1; v != MAX_VEHICLES; ++v)
{
if (!IsVehicleOccupied(v)) SetVehicleToRespawn(v);
}
and
pawn Код:
IsVehicleOccupied(vehicleid)
{
foreach(new i : Player) if (IsPlayerInVehicle(i,vehicleid)) return 1;
return 0;
}
I used foreach because it loops through connected players only; therebefore it's faster!
Re: Respawn Vehicle - Admin Level - Please help -
Miladajir - 06.05.2014
Thanks For Help