SA-MP Forums Archive
Help Downgrade This Code Please - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help Downgrade This Code Please (/showthread.php?tid=185589)



Help Downgrade This Code Please - <Weponz> - 25.10.2010

Ok i just made these weapon commands off the top off my head,Can someone please show me how to make it smaller and add a timer to it so thay cant just spam it and have infinate ammo?

Код:
        if(!strcmp(cmdtext,"/m4",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 31, 500);
        return 1;
        }
        if(!strcmp(cmdtext,"/mp5",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 29, 500);
        return 1;
        }
        if(!strcmp(cmdtext,"/sniper",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 34, 100);
        return 1;
        }
        if(!strcmp(cmdtext,"/rpg",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 35, 50);
        return 1;
        }
        if(!strcmp(cmdtext,"/grenades",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 16, 50);
        return 1;
        }
        if(!strcmp(cmdtext,"/gas",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 17, 50);
        return 1;
        }
        if(!strcmp(cmdtext,"/shot",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 27, 500);
        return 1;
        }
        if(!strcmp(cmdtext,"/knife",true)) if(gTeam[playerid] != CLASS_MERC)
        {
        GivePlayerWeapon(playerid, 4, 1);
        return 1;
        }
Thanks in advanced


Re: Help Downgrade This Code Please - rbN. - 25.10.2010

Top of your script:
pawn Код:
new SpamProtection[MAX_PLAYERS];
OnPlayerConnect:
pawn Код:
SpamProtection[playerid] = 0;
At every weapon command:
pawn Код:
SpamProtection++;
if(SpamProtection == 3) return // ----> (SetTimerEx here, or what ever you want)

-----------
If you want it my way:

OnGameModeInit:
pawn Код:
SetTimer("NoSpam",20000,1);
Somewhere down your script:
pawn Код:
forward NoSpam();

public NoSpam()
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
       
            if(SpamProtection[i] > 0)
            {
                SpamProtection[i] = 0;
            }
           
        }
    }
}
At every weapon command:
pawn Код:
SpamProtection++;
if(SpamProtection == 3) return SendClientMessage(playerid, COLOR_GREEN, "SERVER: Hey, wait a few seconds, spammy boi C:");

------------
For the weapon thingy, if you want to make it smaller, use dialogs or strtok/tmp .


Re: Help Downgrade This Code Please - <Weponz> - 25.10.2010

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
Top of your script:
pawn Код:
new SpamProtection[MAX_PLAYERS];
OnPlayerConnect:
pawn Код:
SpamProtection[playerid] = 0;
At every weapon command:
pawn Код:
SpamProtection++;
if(SpamProtection == 3) return // ----> (SetTimerEx here, or what ever you want)

-----------
If you want it my way:

OnGameModeInit:
pawn Код:
SetTimer("NoSpam",20000,1);
Somewhere down your script:
pawn Код:
forward NoSpam();

public NoSpam()
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
       
            if(SpamProtection[i] > 0)
            {
                SpamProtection[i] = 0;
            }
           
        }
    }
}
At every weapon command:
pawn Код:
SpamProtection++;
if(SpamProtection == 3) return SendClientMessage(playerid, COLOR_GREEN, "SERVER: Hey, wait a few seconds, spammy boi C:");

------------
For the weapon thingy, if you want to make it smaller, use dialogs or strtok/tmp .
Dude this is Spam Protection...I want my** code in one and a timer for it so thay can only get a weapon every 2 mins..


Re: Help Downgrade This Code Please - Calgon - 25.10.2010

Quote:
Originally Posted by <Weponz>
Посмотреть сообщение
Dude this is Spam Protection...I want my** code in one and a timer for it so thay can only get a weapon every 2 mins..
Are you completely retarded? Look at his code, change it and apply it to your commands. The code you wanted to be created would be spam protection, just for the specific command. Does it hurt to think before posting for you?

And if you want to improve your commands, use zcmd.


Re: Help Downgrade This Code Please - rbN. - 25.10.2010

Quote:
Originally Posted by <Weponz>
Посмотреть сообщение
Dude this is Spam Protection...I want my** code in one and a timer for it so thay can only get a weapon every 2 mins..
I just showed my way.. It was an example for your way .


Re: Help Downgrade This Code Please - <Weponz> - 25.10.2010

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
I just showed my way.. It was an example for your way .
Thankyou I See It Now