SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/12/2011, 09:19 PM   #1
Face9000
Banned
 
Join Date: Jan 2010
Location: Pigland
Posts: 3,351
Reputation: 190
Default Optimize this moneycheck?

Hello guys,i've this code:

pawn Code:
forward MoneyCheck();
public MoneyCheck()
{
   for(new i; i < MAX_PLAYERS; i++)
   {
        new cash = GetPlayerMoney(i);
        if(cash > 999999990)
        {
           SetPlayerHealth(i, 0.0);
           SendClientMessage(i, 0x10F441AA, "You forgot to pay the tax,nub.");
           new string[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(i, pName, sizeof(pName));
           format(string, 100, "%s was auto-banned for MoneyHack - $%d.", pName,GetPlayerMoney(i));
           SendClientMessageToAll(COLOR_RED, string);
           GameTextForAll("~r~HAAAAAAAAAAAAAAAAAAX", 3000, 5);
           new sss[128];
           format(sss, sizeof(sss), "You have Been Banned by ANTICHEAT. Reason: Moneyhack.");
           SendClientMessage(i,COLOR_LIGHTBLUE, sss);
           SendClientMessage(i,COLOR_RED, "To Get Unbanned Post an Unban Request at Our Forums");
           SendClientMessage(i,COLOR_LIGHTRED, "Don't Evade, Otherwise you wont get unbanned.");
           new str[136];
           GetPlayerName(i, pName, sizeof(pName));
           format(str,sizeof str,"0,4%s was auto-banned for MoneyHack - $%d.", pName,GetPlayerMoney(i));
           IRC_GroupSay(IRC_Group, EchoChan,str);
           BanLog(string);
           new str2[64];
           format(str2,sizeof str2,"%s", pName);
           Blacklist(str2);
           Ban(i);
           new tmp[128];
           dUserSetINT(tmp).("AccountBanned",1);
     }
   }
}

And this timer on OnGameModeInit:


SetTimer("MoneyCheck", 5000, true);

----

I want to optimize this code,any tips?
Face9000 is offline   Reply With Quote
Old 29/12/2011, 10:18 PM   #2
PowerPC603
High-roller
 
Join Date: Nov 2010
Location: Belgium
Posts: 1,734
Reputation: 238
Default Re: Optimize this moneycheck?

Something like this:
pawn Code:
forward MoneyCheck();
public MoneyCheck()
{
    new Msg[128], Msg2[136], Msg3[64], pName[MAX_PLAYER_NAME], Cash;

    for (new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if (IsPlayerConnected(playerid))
        {
            Cash = GetPlayerMoney(playerid);
            if (Cash > 999999990)
            {
                GetPlayerName(playerid, pName, sizeof(pName));
                SetPlayerHealth(playerid, 0.0);

                SendClientMessage(playerid, 0x10F441AA, "You forgot to pay the tax, nub.");
                format(Msg, sizeof(Msg), "%s was auto-banned for MoneyHack - $%d.", pName, Cash);
                SendClientMessageToAll(COLOR_RED, Msg);
                GameTextForAll("~r~HAAAAAAAAAAAAAAAAAAX", 3000, 5);
                BanLog(Msg);

                format(Msg, sizeof(Msg), "You have Been Banned by ANTICHEAT. Reason: Moneyhack.");
                SendClientMessage(playerid, COLOR_LIGHTBLUE, Msg);
                SendClientMessage(playerid, COLOR_RED, "To Get Unbanned Post an Unban Request at Our Forums");
                SendClientMessage(playerid, COLOR_LIGHTRED, "Don't Evade, Otherwise you wont get unbanned.");

                format(Msg2, sizeof(Msg2), "0,4%s was auto-banned for MoneyHack - $%d.", pName, Cash);
                IRC_GroupSay(IRC_Group, EchoChan, Msg2);

                format(Msg3, sizeof(Msg3), pName);
                Blacklist(Msg3);
                Ban(playerid);

                dUserSetINT(pName).("AccountBanned", 1);
            }
        }
    }
}
__________________
Gamemode: PPC_Trucking
Extras-file (for PPC_Trucking): /delproperty, /evict, /propertyid, /porthouse, /portbus, /properties
------------------------------------------------------------------------------------
PPC-Trucking-V2 (home-hosted, only open on occasion for testing purposes): ppctruckingv2.no-ip.info:7777
Youtube channel: https://www.youtube.com/channel/UC-4...Mpglma8f0Ld-YQ
------------------------------------------------------------------------------------
Filterscripts: PPC_Speedometer - PPC_Housing - PPC_Business
PowerPC603 is offline   Reply With Quote
Old 29/12/2011, 10:20 PM   #3
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 414
Default Re: Optimize this moneycheck?

Another thing I can think of is using foreach for the player loop!
AndreT is offline   Reply With Quote
Old 29/12/2011, 11:29 PM   #4
cessil
High-roller
 
cessil's Avatar
 
Join Date: Apr 2009
Posts: 1,353
Reputation: 296
Default Re: Optimize this moneycheck?

pawn Code:
forward MoneyCheck();
public MoneyCheck()
{
   for(new i; i < MAX_PLAYERS; i++)
   {
        new cash = GetPlayerMoney(i);
        if(cash > 999999990)
        {
           //SetPlayerHealth(i, 0.0);
           SendClientMessage(i, 0x10F441AA, "You forgot to pay the tax,nub.");

           new string[128];
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(i, pName, sizeof(pName));

           format(string, 100, "%s was auto-banned for MoneyHack - $%d.", pName,cash);
           SendClientMessageToAll(COLOR_RED, string);
           GameTextForAll("~r~HAAAAAAAAAAAAAAAAAAX", 3000, 5);

           SendClientMessage(i,COLOR_LIGHTBLUE, "You have Been Banned by ANTICHEAT. Reason: Moneyhack.");
           SendClientMessage(i,COLOR_RED, "To Get Unbanned Post an Unban Request at Our Forums");
           SendClientMessage(i,COLOR_LIGHTRED, "Don't Evade, Otherwise you wont get unbanned.");

           format(str,sizeof str,"0,4%s was auto-banned for MoneyHack - $%d.", pName,cash);
           IRC_GroupSay(IRC_Group, EchoChan,str);
           BanLog(string);
           Blacklist(pName);
           Ban(i);
           new tmp[128];
//im no expert in this ini system but I'm pretty sure this wouldn't work
           dUserSetINT(tmp).("AccountBanned",1);
     }
   }
}

if that's actually from your anticheat then I recommend reading this http://forum.sa-mp.com/showthread.php?t=220089
cessil is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] MoneyCheck™ iPimP™ Filterscripts 46 09/01/2013 07:49 PM
[HELP] Optimize files GPenner Help Archive 0 03/08/2011 05:02 PM
Optimize. Tomejus Help Archive 0 22/02/2011 03:12 PM


All times are GMT. The time now is 06:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.