Raised This Month: $ Target: $400
 0% 

[REQ]Command restriction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
driger38
Senior Member
Join Date: Apr 2011
Old 06-30-2014 , 23:47   [REQ]Command restriction
Reply With Quote #1

I'd wish a plugin that blocks certain command on the first round of the map, and then it limits it so you can use it only once/twice per round.
Cvar for the second part would be great, and flag check.

Flag check: Nonvip user can use it once per round(via cvar) ADMIN_LEVEL_H can use it twice per round (via cvar).

OK, tnx.
if it helps then the command i wish to block: /trade (in every way possible: teamchat, without slash, console command).

I'd appreciate your help

E:
If possible add in this code: (thats all related to /trade command)
PHP Code:
//=====================================================================================================================================================
// Credite General 

new PlayerCredits[33];
new 
File[128], SymbolsName;


//------| Change Name |------//
public ChangeName(idbuffer) {
    if(!
is_user_connected(id))
        return 
FMRES_IGNORED;
    
    static 
Name[32], Val[32];
    
get_user_name(idNamesizeof Name 1);
    
engfunc(EngFunc_InfoKeyValuebuffer"name"Valsizeof Val 1);
    
    if(
equal(ValName))
        return 
FMRES_IGNORED;
    
    
set_task(0.2"client_connect"id);
    return 
FMRES_SUPERCEDE;
}

public 
set_user_credits(idcredits) {
    
PlayerCredits[id] = credits;
    
    
SaveCredits(id)
}
public 
get_user_credits(id) {
    return 
PlayerCredits[id]
}

public 
Depozit(id) {
    if(
cs_get_user_money(id) >= 16000) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 16000 $!g in!t 1 Gold ");
        
set_user_credits(idget_user_credits(id) + 1);
        
cs_set_user_money(idcs_get_user_money(id) - 16000);
    }
    else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 16000 $!g to buy!t 1 Gold");    
    }
    return 
PLUGIN_HANDLED;
}

public 
Retrage(id) {
    if(
cs_get_user_money(id) >= 16000) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You already have!t 16000 $!g , so you can't!t sell gold");
    }
    else if(
PlayerCredits[id]) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 1 Gold!g in!t 16000 $");
        
set_user_credits(idget_user_credits(id) - 1);
        
cs_set_user_money(idcs_get_user_money(id) + 16000);
    }
    else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 1 Gold!g to buy!t 16000 $");    
    }
    return 
PLUGIN_HANDLED;
}



public 
GiveCredits(id) {
    new 
Arg1[32], Arg2[6];
    
    
read_argv(1Arg131);
    
read_argv(2Arg25);
    
    new 
Target cmd_target(idArg18);
    new 
Ammount str_to_num(Arg2);
    
    if(
Target == id) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You can't give gold to!t yourself");
    }
    else if(!
Target) {
        
ChatColor(id"!g* [!t WAR3FT!g ] This player dosen't exist");
    }
    
    else if(
Ammount <= 0) {
        
ChatColor(id"!g* [!t WAR3FT!g ] This Gold number is invalid");
    }
    else if(
Ammount get_user_credits(id)){
        
ChatColor(id"!g* [!t WAR3FT!g ] You can't give more Gold than you have");
    }
    else {        
        new 
TargetName[32], Name[32];
        
get_user_name(TargetTargetName31);
        
get_user_name(idName31);
        
        
set_user_credits(idget_user_credits(id) -  Ammount)
        
//ColorChat(id, "!x03I-ai dat lui!x04 %s!x03 suma de!x04 %d$", TargetName, Ammount);
        
ChatColor(id"!g* [!t WAR3FT!g ] You gave!t %d Gold!g to!t %s"AmmountTargetName);
        
        
set_user_credits(Targetget_user_credits(Target) + Ammount)
        
//ColorChat(Target, "!x03Ai primit de la !x04%s!x03 suma de!x04 %d$", Name, Ammount);
        
ChatColor(Target"!g* [!t WAR3FT!g ] You received!t %d Gold !gfrom!t %s"AmmountName);
    }
}


public 
Show_Credits(id) {
    
ChatColor(id"!g* [!t WAR3FT!g ] You have!t %d Gold"PlayerCredits[id]);
    return 
PLUGIN_HANDLED;
}


public 
Give_Credits(idlevelcid) {
    if(!
cmd_access(idlevelcid2)) {
        return 
PLUGIN_HANDLED;
    }
    new 
arg[23], gplayers[32], numiplayersname[32];
    
get_user_name(idname31);
    
read_argv(1arg23);
    new 
give_credits[5];
    
read_argv(2give_creditscharsmax(give_credits));
    new 
Credits str_to_num(give_credits);
    if(
equali(arg"@T")) {
        
get_players(gplayersnum"e""TERRORIST");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(playersget_user_credits(players) + Credits);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g give!t %i Gold!g to all!t Terrorist"Credits);
            case 
2ChatColor(0"!g*!t %s!g give!t %i Gold!g to all!t Terrorist"nameCredits);
            }
    }
    else if(
equali(arg"@CT")) {
        
get_players(gplayersnum"e""CT");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(playersget_user_credits(players) + Credits);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g give!t %i Gold!g to all!t Counter-Terrorist"Credits);
            case 
2ChatColor(0"!g*!t %s!g give!t %i Gold!g to all!t Counter-Terrorist"nameCredits);
            }
    }
    if(
equali(arg"@All")) {
        
get_players(gplayersnum"a");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(playersget_user_credits(players) + Credits);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g give!t %i Gold!g to all!t Players"Credits);
            case 
2ChatColor(0"!g*!t %s!g give!t %i Gold!g to all!t Players"nameCredits);
            }
    }
    new 
player cmd_target(idarg11);
    if(!
player) {
        return 
PLUGIN_HANDLED;
    }
    
set_user_credits(playerget_user_credits(player) + Credits);
    switch(
get_cvar_num("amx_show_activity")) {
        case 
1ChatColor(player"!g*!t ADMIN!g gave you !t %i Gold"Credits);
        case 
2ChatColor(player"!g*!t %s!g gave you!t %i Gold"nameCredits);
        }
    return 
PLUGIN_HANDLED;
}

public 
Reset_Credits(idlevelcid) {
    if(!
cmd_access(idlevelcid2)) {
        return 
PLUGIN_HANDLED;
    }
    new 
arg[23], gplayers[32], numiplayersname[32];
    
get_user_name(idname31);
    
read_argv(1arg23);
    if(
equali(arg"@T")) {
        
get_players(gplayersnum"e""TERRORIST");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(players0);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g reset!t Gold!g to all!t Terrorist");
            case 
2ChatColor(0"!g*!t %s!g reset!t Gold!g to all!t Terrorist"name);
            }
    }
    
    else if(
equali(arg"@CT")) {
        
get_players(gplayersnum"e""CT");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(players0);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g reset!t Gold!g to all!t Counter-Terrorist");
            case 
2ChatColor(0"!g*!t %s!g reset!t Gold!g to all!t Counter-Terrorist"name);
            }
    }
    if(
equali(arg"@All")) {
        
get_players(gplayersnum"a");
        for(
0numi++) {
            
players gplayers[i];
            if(!
is_user_connected(players))
                continue;
            
set_user_credits(players0);
        }
        switch(
get_cvar_num("amx_show_activity")) {
            case 
1ChatColor(0"!g*!t ADMIN!g reset!t Gold!g to all!t Players");
            case 
2ChatColor(0"!g*!t %s!g reset!t Gold!g to all!t Players"name);
            }
    }
    new 
player cmd_target(idarg11);
    if(!
player) {
        return 
PLUGIN_HANDLED;
    }
    
set_user_credits(player0);
    switch(
get_cvar_num("amx_show_activity")) {
        case 
1ChatColor(player"!g* !tADMIN!g reset your!t Gold");
            case 
2ChatColor(player"!g*!t %s!g reset your!t Gold"name);
        }
    return 
PLUGIN_HANDLED;
}

//------| Save Credits |------//
public SaveCredits(id) {
    new 
Name[32];
    
get_user_name(idName31);

    static 
Data[1024]
    
formatex(Datasizeof(Data) - 1"^"%i^""PlayerCredits[id])
    
    new 
Save[512]
    
format(Save511"^"%s^" %s"NameData)
    
    new 
Line[128], LinieIsPlayer falseArg1[32]
    
    new 
FileOpen fopen(File"rt")
    while(!
feof(FileOpen)) {
        
fgets(FileOpenLine127)
        
trim(Line)

        
parse(LineArg131)
        
        if (
equali(Arg1Name)) {
            
write_file(FileSaveLinie)
            
IsPlayer true
            
break
        }
        
        
Linie++
    }
    
fclose(FileOpen)
    if (!
IsPlayer) {
        
write_file(FileSave, -1)
    }
}

//------| Loading Credits |------//
public LoadCredits(id) {
    new 
Name[32];
    
get_user_name(idName31);
    
    new 
Line[128], IsPlayer falseArg1[32], Arg2[32];
    
    new 
FileOpen fopen(File"rt")
    while(!
feof(FileOpen)) {
        
fgets(FileOpenLine127)
        
trim(Line)
        
        
parse(LineArg131Arg231)
        
        if (
equali(Arg1Name)) {
            
PlayerCredits[id] = str_to_num(Arg2)
            
IsPlayer true
            
break
        }
    }
    
fclose(FileOpen)
    
    if (!
IsPlayer) {
        
PlayerCredits[id] = 1
    
}
}





public 
DepozitXP_A(id) {

new 
XP_TEMP p_data[id][P_XP] - 1500;

if( 
XP_TEMP >= 0)
{        
p_data[id][P_XP]-=1500;
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 1500 Experience!g in!t 1 Gold ");
        
set_user_credits(idget_user_credits(id) + 1);
        
XP_Checkid );
        
}
else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 1500 Experience!g to buy!t 1 Gold");    
    }
    return 
PLUGIN_HANDLED;
}

public 
RetrageXP_A(id) {
    if(
get_user_credits(id)>=1) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 1 Gold!g in!t 1500 Experience");
        
set_user_credits(idget_user_credits(id) - 1);
        
p_data[id][P_XP]+=1500;
        
XP_Checkid );
        
    }
    else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 1 Gold!g to buy!t 1500 Experience");    
    }
    return 
PLUGIN_HANDLED;
    
}



public 
DepozitXP_B(id) {

new 
XP_TEMP p_data[id][P_XP] - 7500;

if( 
XP_TEMP >= 0)
{        
p_data[id][P_XP]-=7500;
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 7500 Experience!g in!t 5 Gold ");
        
set_user_credits(idget_user_credits(id) + 5);
        
XP_Checkid );
        
}
else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 7500 Experience!g to buy!t 5 Gold");    
    }
    return 
PLUGIN_HANDLED;
}

public 
RetrageXP_B(id) {
    if(
get_user_credits(id)>=5) {
        
ChatColor(id"!g* [!t WAR3FT!g ] You changed!t 5 Gold!g in!t 7500 Experience");
        
set_user_credits(idget_user_credits(id) - 5);
        
p_data[id][P_XP]+=7500;
        
XP_Checkid );
        
    }
    else {
        
ChatColor(id"!g* [!t WAR3FT!g ] You need!t 5 Gold!g to buy!t 7500 Experience");    
    }
    return 
PLUGIN_HANDLED;
    


Last edited by driger38; 07-01-2014 at 03:02.
driger38 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 17:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode