Automatic Commands? - 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: Automatic Commands? (
/showthread.php?tid=549458)
Automatic Commands? -
DarknessKnight - 06.12.2014
Is it possible to make 'Auto-Cmds'
Lets say we put a timer that every 60 seconds , the server will do the command /deletecars
to delete empty cars ,how?
Re: Automatic Commands? -
Abagail - 06.12.2014
You can use CallLocalFunction to call a ZCMD command. Example;
pawn Код:
CallLocalFunction("cmd_id", "ii", playerid, giveplayerid);
You can use SetTimerEx for param'd timers. You'll need a playerID to use commands, though, if your trying to make an automatic vehicle deletion system.
Re: Automatic Commands? -
PowerPC603 - 06.12.2014
pawn Код:
// Under OnGameModeInit:
SetTimer("AutoDeleteCars", 60000, true);
// Somewhere else
forward AutoDeleteCars();
public AutoDeleteCars()
{
cmd_deletecars(-1, "");
return 1;
}
COMMAND:deletecars(playerid, params[])
{
if (playerid == -1) SendClientMessageToAll(0xFFFFFFFF, "Auto-deletion of cars");
// Delete all your cars here, but don't use any other playerid's here as -1 is an invalid playerid
// Let the server know that this was a valid command
return 1;
}
Something like this should work.
Re: Automatic Commands? -
DarknessKnight - 07.12.2014
This is My deletecars cmd , i dont really know how to compile it together can you help me?
pawn Код:
CMD:deletecars(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
new Iterator:UnoccupiedVehicles<MAX_VEHICLES>;
foreach(new i : Player) Iter_Add(UnoccupiedVehicles, GetPlayerVehicleID(i));
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
if(!Iter_Contains(UnoccupiedVehicles, v))
{
DestroyVehicle(v);
}
}
}
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: you need to be atleast Admin Level 1 to use this command");
SendClientMessage(playerid, COLOR_GREY, "All Unoccipied Vehicles Deleted!");
return 1;
}
Re: Automatic Commands? -
AviPeker - 08.12.2014
You will need the MathPlugin + Inc
Click Here
pawn Код:
#include a_samp
#include zcmd
#include math
public OnGameModeInit()
{
SetTimer("DelCars", 100000, true); //100,000- every 1'30 min
return 1;
}
forward DelCars();
public DelCars()
{
cmd_deletecars(-1, "");
return 1;
}
COMMAND:delcars(playerid, params[])
{
for(new i = 1; i < MAX_VEHICLES; i ++)
if(MPGetVehicleDriverCount(i) == 0) DestroyVehicle(i);
return 1;
}
This should work.
Re: Automatic Commands? -
DarknessKnight - 10.12.2014
Quote:
Originally Posted by AviPeker
You will need the MathPlugin + Inc
Click Here
pawn Код:
#include a_samp #include zcmd #include math
public OnGameModeInit() { SetTimer("DelCars", 100000, true); //100,000- every 1'30 min return 1; }
forward DelCars(); public DelCars() { cmd_deletecars(-1, ""); return 1; }
COMMAND:delcars(playerid, params[]) { for(new i = 1; i < MAX_VEHICLES; i ++) if(MPGetVehicleDriverCount(i) == 0) DestroyVehicle(i); return 1; }
This should work.
|
Thank you!