Automatic Commands?
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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;
}
Reply
#5

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.
Reply
#6

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)