Help Downgrade This Code Please
#1

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)