AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need HELP with one plugin please help me (https://forums.alliedmods.net/showthread.php?t=61518)

andrius2006x 10-02-2007 15:14

Need HELP with one plugin please help me
 
Sory for my bad english but I wrote a amxx plugin and this plugin works fine but when I wroting that plugin I wroting that the plugin can use only admins who have admin flag t ADMIN_LEVEL_H but this plugin is using by anyone in my server.

Please help me to recode this plugin.
Please recode this plugin that this plugin can use only people ho is in users.ini and have a user flag t ADMIN_LEVEL_H .

Here is the code.

Code:


#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define vipmenu_mygtukai (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
public plugin_modules()
{
require_module("fun")
require_module("cstrike")
}
public plugin_init()
{
register_clcmd( "vipmenu","vipumenu_1")
register_menucmd(register_menuid("vipmenu"), vipmenu_mygtukai, "rodomasmenu_1")
register_plugin("VIP's Privileges", "1.0", "Andriusxxx")
register_dictionary("vips.txt")
register_concmd("vip_awp","vips_awp",ADMIN_LEVEL_H,"Duoda Awp ir sarvus")
register_concmd("vip_he","vipshe",ADMIN_LEVEL_H,"Nusipirkti granate")
register_concmd("vip_fb","vipsfb",ADMIN_LEVEL_H,"Nusipirkti flashbang")
register_concmd("vip_sg","vipssg",ADMIN_LEVEL_H,"Nusipirkti smoke puff")
register_concmd("vip_emka","vipsemka",ADMIN_LEVEL_H,"Nusipirkti m4a1 ginkla")
register_concmd("vip_sig","vips_sig",ADMIN_LEVEL_H,"Nusipirkti sig550 ginkla")
register_concmd("vip_ak","vips_ak",ADMIN_LEVEL_H,"Nusipirkti ak47 ginkla")
register_concmd("vip_deagle","vips_deagle",ADMIN_LEVEL_H,"Nusipirkti desert eagle ginkla")
register_concmd("vip_armor","vips_armor",ADMIN_LEVEL_H,"Nusipirkti sarvus")
}
public vipumenu_1(id) {
show_menu(id, vipmenu_mygtukai, "1: Jusu Pasiulymas^n2: Gauti Awp ir Armor^n3: Gauti HE Granata^n4: Gauti FlashBang^n5: Gauti SmokePuff granata^n6: Gauti emke^n7: Gauti sig550/Aug^n8: Gauti ak47 automata^n9: Gauti Deagle^n0: Gauti Armor^n^n", -1, "vipmenu") // Rodomas menu
}
public rodomasmenu_1(id, key) {
 
switch (key) {
case 0: { //Nera turinio pasiulymas
 
}
case 1: { client_cmd(id,"vip_awp")
 
}
case 2: { client_cmd(id,"vip_he")
 
}
case 3: { client_cmd(id,"vip_fb")
 
}
case 4: { client_cmd(id,"vip_sg")
 
}
case 5: { client_cmd(id,"vip_emka")
 
}
case 6: { client_cmd(id,"vip_sig")
 
}
case 7: { client_cmd(id,"vip_ak")
 
}
case 8: { client_cmd(id,"vip_deagle")
 
}
case 9: client_cmd(id,"vip_armor")
}
return PLUGIN_HANDLED
}
 
public vips_armor(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
give_item(admin_index,"item_kevlar")
give_item(admin_index,"item_assaultsuit")
return PLUGIN_CONTINUE
 
}
public vips_deagle(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_deagle")
give_item(admin_index,"ammo_50ae")
give_item(admin_index,"ammo_50ae")
give_item(admin_index,"ammo_50ae")
give_item(admin_index,"ammo_50ae")
give_item(admin_index,"ammo_50ae")
give_item(admin_index,"ammo_50ae")
return PLUGIN_CONTINUE
 
}
public vips_ak(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_ak47")
give_item(admin_index,"ammo_762nato")
give_item(admin_index,"ammo_762nato")
give_item(admin_index,"ammo_762nato")
return PLUGIN_CONTINUE
 
}
 
public vips_sig(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_sig550")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"weapon_aug")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
return PLUGIN_CONTINUE
 
}
public vips_awp(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_awp")
give_item(admin_index,"ammo_338magnum")
give_item(admin_index,"ammo_338magnum")
give_item(admin_index,"ammo_338magnum")
give_item(admin_index,"item_kevlar")
give_item(admin_index,"item_assaultsuit")
 
return PLUGIN_CONTINUE
}
public vipsemka(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_m4a1")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
give_item(admin_index,"ammo_556nato")
return PLUGIN_CONTINUE
}
public vipshe(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_hegrenade")
give_item(admin_index,"ammo_hegrenade")
 
return PLUGIN_CONTINUE
}
public vipsfb(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_flashbang")
give_item(admin_index,"ammo_flashbang")
give_item(admin_index,"ammo_flashbang")
 
return PLUGIN_CONTINUE
}
public vipssg(admin_index)
{
new adminname[32]
get_user_name(admin_index,adminname,32)
 
give_item(admin_index,"weapon_smokegrenade")
give_item(admin_index,"ammo_smokegrenade")
 
return PLUGIN_CONTINUE
}

I try very more codes but with all off my try's i have got always erorrs :cry:
I Spend very much time on this plugin Please someone help me to code this plugin.
I want recode this plugin that only users with ADMIN_LEVEL_H can use this menu.
I hope you get my wish :wink: :wink:
Good luck and thanks for help. :wink:

M249-M4A1 10-02-2007 17:03

Re: Need HELP with one plugin please help me
 
You forgot to check for the access levels in each of your procedures.
You should also use return PLUGIN_HANDLED at the end of each procedure, instead of PLUGIN_CONTINUE, because you will end up getting Unknown command errors.

EDIT (In accordance to X-Script's post): I changed admin_index to id, as it is the more commonly used variable to hold an id. admin_index was fine, but it's too much to type over and over again.

Try this:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define vipmenu_mygtukai (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
public plugin_modules()
{
    
require_module("fun")
    
require_module("cstrike")
}
public 
plugin_init()
{
    
register_clcmd"vipmenu","vipumenu_1")
    
register_menucmd(register_menuid("vipmenu"), vipmenu_mygtukai"rodomasmenu_1")
    
register_plugin("VIP's Privileges""1.0""Andriusxxx")
    
register_dictionary("vips.txt")
    
register_concmd("vip_awp","vips_awp",ADMIN_LEVEL_H,"Duoda Awp ir sarvus")
    
register_concmd("vip_he","vipshe",ADMIN_LEVEL_H,"Nusipirkti granate")
    
register_concmd("vip_fb","vipsfb",ADMIN_LEVEL_H,"Nusipirkti flashbang")
    
register_concmd("vip_sg","vipssg",ADMIN_LEVEL_H,"Nusipirkti smoke puff")
    
register_concmd("vip_emka","vipsemka",ADMIN_LEVEL_H,"Nusipirkti m4a1 ginkla")
    
register_concmd("vip_sig","vips_sig",ADMIN_LEVEL_H,"Nusipirkti sig550 ginkla")
    
register_concmd("vip_ak","vips_ak",ADMIN_LEVEL_H,"Nusipirkti ak47 ginkla")
    
register_concmd("vip_deagle","vips_deagle",ADMIN_LEVEL_H,"Nusipirkti desert eagle ginkla")
    
register_concmd("vip_armor","vips_armor",ADMIN_LEVEL_H,"Nusipirkti sarvus")
}
public 
vipumenu_1(id) {
    
show_menu(idvipmenu_mygtukai"1: Jusu Pasiulymas^n2: Gauti Awp ir Armor^n3: Gauti HE Granata^n4: Gauti FlashBang^n5: Gauti SmokePuff granata^n6: Gauti emke^n7: Gauti sig550/Aug^n8: Gauti ak47 automata^n9: Gauti Deagle^n0: Gauti Armor^n^n", -1"vipmenu"// Rodomas menu
    
return PLUGIN_HANDLED
}
public 
rodomasmenu_1(idkey) {
    
    switch (
key) {
        case 
0: { //Nera turinio pasiulymas
            
        
}
        case 
1: { client_cmd(id,"vip_awp")
            
        }
        case 
2: { client_cmd(id,"vip_he"
            
        }
        case 
3: { client_cmd(id,"vip_fb"
            
        }
        case 
4: { client_cmd(id,"vip_sg"
            
        }
        case 
5: { client_cmd(id,"vip_emka"
            
        }
        case 
6: { client_cmd(id,"vip_sig"
            
        }
        case 
7: { client_cmd(id,"vip_ak"
            
        }
        case 
8: { client_cmd(id,"vip_deagle"
            
        }
        case 
9client_cmd(id,"vip_armor"
        }
    return 
PLUGIN_HANDLED 
}

public 
vips_armor(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
give_item(id,"item_kevlar")
    
give_item(id,"item_assaultsuit")
    return 
PLUGIN_HANDLED
    
}
public 
vips_deagle(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_deagle")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    
give_item(id,"ammo_50ae")
    return 
PLUGIN_HANDLED
    
}
public 
vips_ak(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_ak47")
    
give_item(id,"ammo_762nato")
    
give_item(id,"ammo_762nato")
    
give_item(id,"ammo_762nato")
    return 
PLUGIN_HANDLED
    
}

public 
vips_sig(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_sig550")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    
give_item(id,"weapon_aug")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    return 
PLUGIN_HANDLED
    
}
public 
vips_awp(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_awp")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"ammo_338magnum")
    
give_item(id,"item_kevlar")
    
give_item(id,"item_assaultsuit")
    
    return 
PLUGIN_HANDLED
}
public 
vipsemka(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_m4a1")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    
give_item(id,"ammo_556nato")
    return 
PLUGIN_HANDLED
}
public 
vipshe(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_hegrenade")
    
give_item(id,"ammo_hegrenade")
    
    return 
PLUGIN_HANDLED
}
public 
vipsfb(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_flashbang")
    
give_item(id,"ammo_flashbang")
    
give_item(id,"ammo_flashbang")
    
    return 
PLUGIN_HANDLED
}
public 
vipssg(idlevelcid)
{
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED
        
    
new adminname[32]
    
get_user_name(id,adminname,32)
    
    
give_item(id,"weapon_smokegrenade")
    
give_item(id,"ammo_smokegrenade")
    
    return 
PLUGIN_HANDLED



X-Script 10-02-2007 17:18

Re: Need HELP with one plugin please help me
 
Um.. ?

PHP Code:

admin_index 

change to

PHP Code:

id 

I've never seen any scripter use admin_index, but you should use ID instead.

EDIT: and trust me, i've seen ALOT of codes.

M249-M4A1 10-02-2007 17:40

Re: Need HELP with one plugin please help me
 
I updated the code I posted, I changed admin_index to id and give him a reason why.

Lord_Destros 10-02-2007 19:09

Re: Need HELP with one plugin please help me
 
Plugins don't require a plugin_modules function (and haven't for quite a while). Having a menu that sends a command back to the client, who then automatically sends the command back to the server is a tad bit inefficient (and annoying since you can't exit the menu) but meh...

andrius2006x 10-03-2007 13:06

Re: Need HELP with one plugin please help me
 
Thanks man ;)

And one more question

For waht is needed cid ??? i dont know :|

M249-M4A1 10-03-2007 15:36

Re: Need HELP with one plugin please help me
 
cid holds the command's id; you don't have to worry about its exact details though


All times are GMT -4. The time now is 16:15.

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