Need fs or pawn : Respawncars all the server or anti car spaming in the air
#1

my sv is roleplay , now the troller come so many and make my server with car spaming , they focus all vehicle in server make them freeze in the air either make the server so lag ... Anyone can help i need cmd to respawn all vehicle or anti cheat that

Thanks to see my topic , hope your answer sorry bad english
Reply
#2

Try something like this:

pawn Код:
for(new a = 0; a < MAX_VEHICLES; a++) {
    new bool:o = false;
    for(new b = 0; b < MAX_PLAYERS; b++) if(GetPlayerVehicleID(b) == a) o = true;
    if(o == true) SetVehicleToRespawn(a);
}
Reply
#3

How to add that , im newbie

please help me
Reply
#4

You have a few options, you could set it on a timer, call it from a command, or whatever you would like to do.

For a timer:
pawn Код:
//top of script
forward ResetTimer();

//in OnGameModeInit
SetTimer("ResetTimer", 60000, 1); //1 second = 1000 milliseconds.  60000 = every 60 seconds

//at the bottom of script
public ResetTimer()
{
    for(new a = 0; a < MAX_VEHICLES; a++) {
        new bool:o = false;
        for(new b = 0; b < MAX_PLAYERS; b++) if(GetPlayerVehicleID(b) == a) o = true;
        if(o == true) SetVehicleToRespawn(a);
    }
}
Or in a command:
pawn Код:
//in OnPlayerCommandText
    if(strcmp("/resetcars", cmdtext, true) == 0)
    {
        for(new a = 0; a < MAX_VEHICLES; a++) {
            new bool:o = false;
            for(new b = 0; b < MAX_PLAYERS; b++) if(GetPlayerVehicleID(b) == a) o = true;
            if(o == true) SetVehicleToRespawn(a);
        }
        return 1;
    }
Reply
#5

thanks a lot but...

error i cant add your pawn
Reply
#6

Quote:
Originally Posted by jesdynguyen
Посмотреть сообщение
thanks a lot but...

error i cant add your pawn
Do you have scripting experience? Or probably, you are using a downloaded GM?

pawn Код:
stock IsVehicleOccupied(vehicleid)
{
    for(new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == 0) return 1;
    }
    return 0;
}

stock RespawnUnoccupiedVehicles()
{
    for(new i = 1; i != MAX_VEHICLES; ++i)
    {
        if(!IsVehicleOccupied(i) && IsValidVehicle(i))
        {
            SetVehicleToRespawn(i);
        }
    }
}
In a cmd:

pawn Код:
CMD:respawnallcars(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Not allowed to use this."), return 0;
    RespawnUnoccupiedVehicles();
    return 1;
}
Reply
#7

im using gamemode roleplay , i just use gamemode available for open the server , iam not experience for scripting can you teach me specified more than

can i send you a message
Reply
#8

What is the error you where getting?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)