SAMP Server lag
#1

My SAMP server is lagging really quite bad when there's alot of players online, by having giant lag spikes.
Usually happens with 5+ players, although small spikes still appear even though there's less than 5.

I mean it might be because of bad script optimization?
Is there maybe a program to detect what's causing the lag or something?
Reply
#2

Try this to see if any functions are causing your problem.
Reply
#3

I got around 50.000 lines, how should i check if any functions cause lag?

EDIT: Nvm didn't saw you posted a link, i actually tried that program, but i cant get it working, i put it in plugins file, put the new stuff in my .cfg and configure it, but it doesn't seem to do anything it should.
Reply
#4

Nine chances out of ten it's OnPlayerUpdate.
Reply
#5

I've hard people talking about OnPlayerUpdate bein able to cause alot of lag, but i dont know how much is too much.

Does this look fine?:
pawn Код:
public OnPlayerUpdate(playerid)
{
    SetProgressBarValue(Hunger[playerid], Hungry[ playerid ] * 5.0);
    UpdateProgressBar(Hunger[playerid], playerid);
    UpdateHP(playerid);
    if(IsPlayerConnected(playerid) && IsPlayerLoggedIn(playerid))
    {
        if(!BoomboxStream[playerid])
        {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(Boombox[i])
                    {
                        if(IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
                        {
                            PlayAudioStreamForPlayer(playerid, BoomboxURL[i], bpos[i][0], bpos[i][1], bpos[i][2], 30, 1);
                            BoomboxPlayer[playerid] = i;
                            BoomboxStream[playerid] = 1;
                            SendClientMessage(playerid, COLOR_GREY, " You are listening to music coming out of a nearby boombox.");
                        }
                    }
                }
            }
        }
        else
        {
            new i = BoomboxPlayer[playerid];
            if(!IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
            {
                BoomboxStream[playerid] = 0;
                BoomboxPlayer[playerid] = -1;
                StopAudioStreamForPlayer(playerid);
                SendClientMessage(playerid, COLOR_GREY, " You have went far away from the boombox.");
            }
        }
       
        if(TempPoses[playerid][3]==1.0)
        SetPlayerPos(playerid,TempPoses[playerid][0],TempPoses[playerid][1],TempPoses[playerid][2]);
        //return 1;
       
        // Boxing
        if(Boxing[playerid] && !BoxTime)
        {
            new string[128];
            new Float:bH; GetPlayerHealth(playerid, bH);
            if(bH <= 20)
            {
                // Getting other boxer's ID
                new playerb = -1;
                foreach(Player, i)
                {
                    if(Boxing[i] && i != playerid) playerb = i;
                }
                if(playerb != -1)
                {
                    format(string, sizeof(string), "Boxing Ring: The boxing match has ended, %s has won the match.", RPN(playerb));
                    SendGymMessage(COLOR_WHITE, string);
                    // Putting them out of the ring
                    SetPlayerPos(playerb, 760.9759,4.7187,1000.7084);
                    SetPlayerFacingAngle(playerb, 268.9407);
                    SetPlayerPos(playerid, 760.9759,6.1794,1000.7093);
                    SetPlayerFacingAngle(playerid, 268.9407);
                    // Giving the winner extra skill point
                    new oldj = strval(RPJL(playerb, JOB_BOXER));
                    PlayerInfo[playerb][pJobSkill][JOB_BOXER] ++;
                    new newj = strval(RPJL(playerb, JOB_BOXER));
                    if(oldj < newj)
                    {
                        format(string, sizeof(string), "** Your Boxer level is now %d, you can now cause %d more damage. **", newj, (newj*2)-2);
                        SendClientMessage(playerb, COLOR_YELLOW, string);
                    }
                    //
                    SendClientMessage(playerb, COLOR_LIME, " You have won the boxing match.");
                    SendClientMessage(playerid, COLOR_LIGHTRED, " You have lost the boxing match.");
                    // Giving Bids
                    new winner = pBoxer[playerb];
                    foreach(Player, i)
                    {
                        if(BidBoxer[i] == winner)
                        {
                            new percent, profit;
                            percent = (BidAmount[i]/BoxerBid[winner]) * 100;
                            profit = (percent * BoxerBid[pBoxer[playerid]]) / 100;
                            GiveZaiatMoney(i, BidAmount[i] + profit);
                            format(string, sizeof(string), " You have won $%d from bidding in the match, the money you bid has been returned as well.", profit);
                            SendClientMessage(i, COLOR_LIME, string);
                        }
                        BidAmount[i] = 0;
                        BidBoxer[i] = 0;
                    }
                    for(new w = 0; w < 13; w++)
                    {
                        GiveZaiatWeapon(playerb, PlayerInfo[playerb][pWeapon][w], PlayerInfo[playerb][pWeaponAmmo][w]);
                    }
                }
                for(new w = 0; w < 13; w++)
                {
                    GiveZaiatWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
                }
                // Resetting Values
                BoxingMatch = 0;
                Boxer[1] = -1;
                pBoxer[playerb] = 0;
                Boxer[2] = -1;
                pBoxer[playerid] = 0;
                Boxing[playerb] = 0;
                Boxing[playerid] = 0;
                BoxerBid[1] = 0;
                BoxerBid[2] = 0;
            }
        }
        // Spikes
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(!IsACop(playerid) && !IsAFBI(playerid) && !IsARCSD(playerid) && !IsASWAT(playerid) && !IsASATF(playerid))
            {
                for(new i = 0; i < sizeof(SpikeInfo); i++)
                {
                    if(IsPlayerInRangeOfPoint(playerid, 3.0, SpikeInfo[i][sX], SpikeInfo[i][sY], SpikeInfo[i][sZ]))
                    {
                        if(SpikeInfo[i][sCreated] == 1)
                        {
                            new panels, doors, lights, tires;
                            new carid = GetPlayerVehicleID(playerid);
                            GetVehicleDamageStatus(carid, panels, doors, lights, tires);
                            tires = encode_tires(1, 1, 1, 1);
                            UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
                        }
                    }
                }
            }
        }
        // Fuel
        new vehicleid = GetPlayerVehicleID(playerid);
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Fuel[vehicleid] <= 0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective, string[128];
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            if(engine)
            {
                SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
                {SetVehicleParamsEx(vehicleid, 0, 0, 0, PlayerInfo[playerid][vLocked], 0, 0, 0);}
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
                {SetVehicleParamsEx(vehicleid, 0, 0, 0, PlayerInfo[playerid][vVLocked], 0, 0, 0);}
                if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pBVeh])
                {SetVehicleParamsEx(vehicleid, 0, 0, 0, PlayerInfo[playerid][vBLocked], 0, 0, 0);}
                format(string, sizeof(string), "* %s's vehicle stops as it has no fuel in its tank.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            }
        }
        // Drag
        if(Dragged[playerid] != -1)
        {
            new playerb = Dragged[playerid];
            new Float:pos[3];
            GetPlayerPos(playerb, pos[0], pos[1], pos[2]);
            SetPlayerPos(playerid, pos[0]+0.5, pos[1]+0.5, pos[2]);
            SetPlayerInterior(playerid, GetPlayerInterior(playerb));
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
        }
        // AntiCS
        new Keys, ud, lr;
        GetPlayerKeys(playerid, Keys, ud, lr);
        if(CheckCrouch[playerid] == 1) {
            switch(WeaponID[playerid]) {
                case 23..25, 27, 29..34, 41: {
                    if((Keys & KEY_CROUCH) && !((Keys & KEY_FIRE) || (Keys & KEY_HANDBRAKE)) && GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK ) {
                        if(Ammo[playerid][GetPlayerWeapon(playerid)] > GetPlayerAmmo(playerid)) {
                            OnPlayerCBug(playerid);
                        }
                    }
                    //else SendClientMessage(playerid, COLOR_RED, "Failed in onplayer update");
                }
            }
        }

        if(!ud && !lr) { NotMoving[playerid] = 1; /*OnPlayerKeyStateChange(playerid, Keys, 0);*/ }
        else { NotMoving[playerid] = 0; /*OnPlayerKeyStateChange(playerid, Keys, 0);*/ }
        // Alt-Tab detection
        AltTabbed[playerid] = 0;
        // Speedlimit
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Speedlimit[playerid])
        {
            new a, b, c;
            GetPlayerKeys(playerid, a, b ,c);
            if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > Speedlimit[playerid])
            {
                new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - Speedlimit[playerid];
                ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed);
            }
        }
        // Ping Update
        if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
        {
            new string[64];
            format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~r~%s's Ping: ~w~%d", NORPN(Specid[playerid]), GetPlayerPing(Specid[playerid]));
            GameTextForPlayer(playerid, string,1000, 3);
        }
        // Money Anticheat
        if(GetPlayerMoney(playerid) != PlayerInfo[playerid][pMoney])
        {
            ResetPlayerMoney(playerid);
            GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
        }
        // Speedometer
        if(Speedo[playerid] && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new string[64], speed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0);
            //format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~r~Speedometer: ~w~%d MPH", speed);
            format(string,sizeof(string),"MPH: %d", speed);
            TextDrawSetString(speedometer, string);
            //GameTextForPlayer(playerid, string,1000, 3);
        }
        // SpeedCheck
        if(USE_ANTI_SPEEDHACK == true)
        {
            if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && PlayerInfo[playerid][pAdmin] < 2)
            {
                new speed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0);
                if(speed > 270 && GetVehicleModel(GetPlayerVehicleID(playerid)) != 519 && GetVehicleModel(GetPlayerVehicleID(playerid)) != 553 || speed > 300)
                {
                    new string[128];
                    format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s might be using speed hacks (%d MPH)", NORPN(playerid), speed);
                    new Float:X, Float:Y, Float:Z;
                    GetPlayerPos(playerid, X, Y, Z);
                    RemovePlayerFromVehicle(playerid);
                    SetPlayerPos(playerid, X, Y, Z+5);
                    Log("logs/hack.log", string);
                    SendAdminMessage(COLOR_DARKRED, 1, string);
                }
            }
        }
        // Jetpack Hack
        if(USE_ANTI_JETPACK == true)
        {
            if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK && JetPack[playerid] == 0 && PlayerInfo[playerid][pAdmin] < 2)
            {
                new string[74 + MAX_PLAYER_NAME];
                format( string, sizeof( string ), "{FF0000}[Admin Warn]{FF6347} %s may possibly be jetpack hacking.", NORPN(playerid));
                new Float:Pos[3];
                GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
                SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]+5);
                Log("logs/hack.log", string);
                SendAdminMessage(COLOR_DARKRED, 1, string);
            }
        }
        // Nask Update
        if(PlayerInfo[playerid][pMaskOn] == 1)
            {
                for(new i; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        ShowPlayerNameTagForPlayer(i, playerid, 0);
                    }
              }
         }
        if(PlayerInfo[playerid][pMaskOn] == 0)
    {
    //PlayerInfo[playerid][pMask] = 0;
        for(new i; i<MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                ShowPlayerNameTagForPlayer(i, playerid, 1);
            }
        }
    }
        // Fuel
        if(fMeter[playerid] && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new string[64];
            //format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~r~Fuel: ~w~%d%", Fuel[GetPlayerVehicleID(playerid)]);
            //GameTextForPlayer(playerid, string,1000, 3);
            format(string,sizeof(string),"Fuel: %d%", Fuel[GetPlayerVehicleID(playerid)]);
            TextDrawSetString(fuelmeter, string);
        }
    }
    return 1;
}
And yes some of the bits i just poorly cut out because i want to remove them, but haven't tested if it works, so i can always put it back.
Reply
#6

This is just too much for OnPlayerUpdate.
It processes that huge block of code, with several loops, alot of server-client traffic and more over 30 times per second, for each player.

Most of it could be placed inside a timer that runs every second.

Also, anti-money cheat, anti-jetpack cheat and such things should be placed in a 1-second timer, that's fast enough.
Having a jetpack and getting kicked within 30 milliseconds isn't really required.
Even if you used a 5-second timer for anti-jetpack, it would be enough as players won't get very far in 5 seconds with a jetpack.

Updating a textdraw to display fuel-status 30 times per second isn't required either.
Unless you allow vehicles to run out of fuel inside a few seconds and you want a smooth decline of the readout.

Just look at every block of code and ask yourself if it's really required to have that block of code executed 30 times per second.

Or even more as some players disable their framerate limiter, then OnPlayerUpdate is called even more per second.
Reply
#7

By any chance, avoid using big loops in OnPlayerUpdate. Even simple-looking loops can take a whole millisecond to complete, so thats 1 millisecond of lag every 30ms. Having 5 players would mean 5ms lag every 30ms (16%) which already results in intolerable lag.

The number 1 rule is to do stuff just when its needed, instead of checking iteratively if a certain condition applies to doing some stuff. This is especially important for GUI stuff.
Reply
#8

It's usually OnPlayerUpdate. In there, things will usually be set on timers, every time the server has to load those lines (especially more then one), causes the server to lag.
Reply
#9

The server is hosted, and it only tells me the CPU usage is like 9% at it's highest, nomatter when i check.
I'll try putting most of it under timers instead and see how it works out.
Reply
#10

EDIT: Nevermind the last thing i said in this post, but now there's noticeably big lag when players disconnect...
How can i fix this?
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(CurrentCCTV[playerid] > -1)
    {
        KillTimer(KeyTimer[playerid]);
        TextDrawHideForPlayer(playerid, TD);
    }
    CurrentCCTV[playerid] = -1;
    // IRC
    /*new leaveMsg[128], name[MAX_PLAYER_NAME], reasonMsg[8];
    switch(reason)
    {
        case 0: reasonMsg = "Timeout";
        case 1: reasonMsg = "Leaving";
        case 2: reasonMsg = "Kicked";
    }
    GetPlayerName(playerid, name, sizeof(name));
    format(leaveMsg, sizeof(leaveMsg), "02[%d] 03*** %s has left the server. (%s)", playerid, name, reasonMsg);
    IRC_GroupSay(groupID, IRC_CHANNEL, leaveMsg);*/

    if(IsPlayerLoggedIn(playerid)) {SaveChar(playerid);}
    //LastSeen(playerid); // LastSeen System
    KillTimer(PingTimer[playerid]);
    if(OldCar[playerid] != INVALID_VEHICLE_ID) PassengerInCar[OldCar[playerid]][PassengerSeat[playerid]] = INVALID_PLAYER_ID;
    Boombox[playerid] = 0;
    BoomboxPlayer[playerid] = -1;
    BoomboxStream[playerid] = 0;
    bpos[playerid][0] = 0; bpos[playerid][1] = 0; bpos[playerid][2] = 0; bpos[playerid][3] = 0;
    format(BoomboxURL[playerid], 256, "");
    if(IsValidDynamicObject(BoomboxObject[playerid])) DestroyDynamicObject(BoomboxObject[playerid]);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(BoomboxPlayer[i] == playerid)
            {
                BoomboxStream[i] = 0;
                BoomboxPlayer[i] = -1;
                StopAudioStreamForPlayer(i);
                SendClientMessage(i, COLOR_GREY, " The boombox creator has disconnected from the server.");
            }
        }
    }
    DestroyDynamic3DTextLabel(ado[playerid]);
    DestroyDynamic3DTextLabel(ame[playerid]);
    amestatus[playerid] = 0;
    adostatus[playerid] = 0;
    if(IsPlayerCuffed(playerid))
    {
            new string[128];
            GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
            ClearZaiatWantedLevels(playerid);
            SetPlayerColor(playerid, TRANSPARENT_ORANGE);
            PlayerInfo[playerid][pPrison] = 2;
            PlayerInfo[playerid][pPrisonTime] = 10*60;
            format(PlayerInfo[playerid][pPrisonReason], 64, "Avoiding Arrest");
            format(PlayerInfo[playerid][pPrisonBy], 32, "AutoPrison");
            SetPlayerInterior(playerid, 2);
            SetPlayerVirtualWorld(playerid, 1);
            new RandomCell = random(sizeof(RandomPrison));
            SetPlayerFacingAngle(playerid, RandomPrison[RandomCell][3]);
            TogglePlayerControllable(playerid, 0);
            SetTimerEx("EnterExitTimer", 4000, false, "i", playerid);
            SetPlayerPos(playerid, RandomPrison[RandomCell][0], RandomPrison[RandomCell][1], RandomPrison[RandomCell][2]);
            SetCameraBehindPlayer(playerid);
            format(string, sizeof(string), "{FF0000}[Admin]{FF6347} %s has been auto-prisoned, reason: Avoiding Arrest/Quitting in jail", RPN(playerid));
            SendClientMessageToAll(COLOR_LIGHTRED, string);
            Log("logs/prison.log", string);
            format(string, sizeof(string), " You have been auto-prisoned for %d minutes (%d seconds)", PlayerInfo[playerid][pPrisonTime]/60, PlayerInfo[playerid][pPrisonTime]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }
    // Bank Robbery
    if(BankRobber[playerid])
    {
        new Rob = BankRobber[playerid]-1, string[128];
        DisablePlayerCheckpoint(playerid);
        BankRobbersCount --;
        format(BankRobbers[Rob], MAX_PLAYER_NAME, "");
        DeliverMoney[playerid] = 0;
        //
        foreach(Player, i)
        {
            if(BankRobber[i] || PlayerInfo[i][pFac] == 1)
            {
                if(Rob == 0) TextDrawHideForPlayer(i, Textdraw1);
                else if(Rob == 1) TextDrawHideForPlayer(i, Textdraw2);
                else if(Rob == 2) TextDrawHideForPlayer(i, Textdraw3);
                else if(Rob == 3) TextDrawHideForPlayer(i, Textdraw4);
                else if(Rob == 4) TextDrawHideForPlayer(i, Textdraw5);
            }
        }
        format(string, sizeof(string), "** %s has disconnected and has failed the robbery. **", RPN(playerid));
        SendRobberyMessage(COLOR_LIGHTRED, string);
        BankRobber[playerid] = 0;
        if(BankRobbersCount == 0)
        {
            TextDrawHideForAll(Area5);
            TextDrawHideForAll(Textdraw1);
            TextDrawHideForAll(Textdraw2);
            TextDrawHideForAll(Textdraw3);
            TextDrawHideForAll(Textdraw4);
            TextDrawHideForAll(Textdraw5);
            BankRobbery = 0;
            RobberyStarted = 0;
            format(string, sizeof(string), "** The bank robbery has ended, $%d were stolen and $%d were saved. **", TotalStolen*50000, (TotalRobbers*50000-(TotalStolen*50000)));
            SendClientMessageToAll(COLOR_YELLOW, string);
            TotalRobbers = 0;
            new copsonline;
            foreach(Player, i)
            {
                if(IsACop(i)) copsonline++;
                if(IsARCSD(i)) copsonline++;
                if(IsAFBI(i)) copsonline++;
            }
            foreach(Player, i)
            {
                if(IsACop(i))
                {
                    new Saved = (TotalRobbers*50000-(TotalStolen*50000));
                    GiveZaiatMoney(i, Saved/copsonline);
                    format(string, sizeof(string), "** You have received your cut from the saved money. ($%d)", Saved/copsonline);
                    SendClientMessage(i, COLOR_LIME, string);
                }
            }
        }
    }
    // Boxing
    new string[128];
    if(Boxing[playerid])
    {
        // Getting other boxer's ID
        new playerb = -1;
        foreach(Player, i)
        {
            if(Boxing[i] && i != playerid) playerb = i;
        }
        if(playerb != -1)
        {
            format(string, sizeof(string), "Boxing Ring: The boxing match has ended, %s has won the match.", RPN(playerb));
            SendGymMessage(COLOR_WHITE, string);
            // Putting them out of the ring
            SetPlayerPos(playerb, 760.9759,4.7187,1000.7084);
            SetPlayerFacingAngle(playerb, 268.9407);
            SetPlayerPos(playerid, 760.9759,6.1794,1000.7093);
            SetPlayerFacingAngle(playerid, 268.9407);
            // Giving the winner extra skill point
            new oldj = strval(RPJL(playerb, JOB_BOXER));
            PlayerInfo[playerb][pJobSkill][JOB_BOXER] ++;
            new newj = strval(RPJL(playerb, JOB_BOXER));
            if(oldj < newj)
            {
                format(string, sizeof(string), "** Your Boxer level is now %d, you can now cause %d more damage. **", newj, (newj*2)-2);
                SendClientMessage(playerb, COLOR_YELLOW, string);
            }
            //
            SendClientMessage(playerb, COLOR_LIME, " You have won the boxing match.");
            SendClientMessage(playerid, COLOR_LIGHTRED, " You have lost the boxing match.");
            // Giving Bids
            new winner = pBoxer[playerb];
            foreach(Player, i)
            {
                if(BidBoxer[i] == winner)
                {
                    new percent, profit;
                    percent = (BidAmount[i]/BoxerBid[winner]) * 100;
                    profit = (percent * BoxerBid[pBoxer[playerid]]) / 100;
                    GiveZaiatMoney(i, BidAmount[i] + profit);
                    format(string, sizeof(string), " You have won $%d from bidding in the match, the money you bid has been returned as well.", profit);
                    SendClientMessage(i, COLOR_LIME, string);
                }
                BidAmount[i] = 0;
                BidBoxer[i] = 0;
            }
            for(new w = 0; w < 13; w++)
            {
                GiveZaiatWeapon(playerb, PlayerInfo[playerb][pWeapon][w], PlayerInfo[playerb][pWeaponAmmo][w]);
            }
        }
        for(new w = 0; w < 13; w++)
        {
            GiveZaiatWeapon(playerid, PlayerInfo[playerid][pWeapon][w], PlayerInfo[playerid][pWeaponAmmo][w]);
        }
        // Resetting Values
        BoxingMatch = 0;
        Boxer[1] = -1;
        pBoxer[playerb] = 0;
        Boxer[2] = -1;
        pBoxer[playerid] = 0;
        Boxing[playerb] = 0;
        Boxing[playerid] = 0;
        BoxerBid[1] = 0;
        BoxerBid[2] = 0;
        if(BoxTime)
        {
            TogglePlayerControllable(playerb, 1);
            KillTimer(BoxTimer);
        }
    }
    // The rest
    switch(reason)
    {
        case 0: format(string, sizeof(string), "* %s has left the server. (Timeout)", RPN(playerid));
        case 1: format(string, sizeof(string), "* %s has left the server. (Leaving)", RPN(playerid));
        case 2: format(string, sizeof(string), "* %s has left the server. (Kicked/Banned)", RPN(playerid));
    }
    SendNearbyMessage(playerid, 10, string, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW, COLOR_YELLOW);
    foreach(Player, i)
    {
        if(JoinMessages[i])
        {
            SendClientMessage(i, COLOR_LIGHTBLUE, string);
        }
    }
    foreach(Player, i)
    {
        if(Specid[i] == playerid)
        {
            Spec[i] = 0;
            Specid[i] = -1;
            TogglePlayerSpectating(i, 0);
            SetPlayerVirtualWorld(i, PlayerInfo[playerid][pVW]);
            SetPlayerInterior(i, PlayerInfo[playerid][pInt]);
            SetPlayerPos(i, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
            SendClientMessage(i, COLOR_WHITE, "You have stopped spectating.");
        }
    }
    // Clearing AD
    for(new i=0; i<MAX_ADS; i++)
    {
        if(strfind(AD[i], RPN(playerid)) != -1)
        {
            format(AD[i], 128, "");
        }
    }
    // End of Clearing AD
    ClearChar(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)