Raised This Month: $12 Target: $400
 3% 

if equal steamid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 06-03-2014 , 17:10   if equal steamid
Reply With Quote #1

How to read two or more steamids with if equal?
PHP Code:
if(equal(szSteamID"STEAM_x:x:xxxxxxxx" and "STEAM_x:x:xxxxxxxx" and more)) 
CHE4TER is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-03-2014 , 18:38   Re: if equal steamid
Reply With Quote #2

Use a const and loop trough all the SteamIDs in it. I think this is the best way to read two or more steamids at once.
EDIT: Moved that new variable for name outside the loop.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new const SteamIDs[][]=
{
    
"",
    
"STEAM_x:x:xxxxxxxx",
    
"STEAM_y:y:yyyyyyyy",
    
"STEAM_z:z:zzzzzzzz"
}

public 
plugin_init() {
    
    
register_clcmd("say /test""CheckSteamIds")
}

public 
CheckSteamIds(id)
{
    new 
szSteamID[32]
    
get_user_authid(idszSteamIDcharsmax(szSteamID))
    for(new 
1sizeof SteamIDsi++)
    {
        if(
equal(szSteamIDSteamIDs[i]))
        {
            
//Do stuff needed :)
        
}
    }

__________________

Last edited by Flick3rR; 06-13-2014 at 18:34.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-04-2014 , 04:45   Re: if equal steamid
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
Use a const and loop trough all the SteamIDs in it. I think this is the best way to read two or more steamids at once.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new const SteamIDs[][]=
{
    
"",
    
"STEAM_x:x:xxxxxxxx",
    
"STEAM_y:y:yyyyyyyy",
    
"STEAM_z:z:zzzzzzzz"
}

public 
plugin_init() {
    
    
register_clcmd("say /test""CheckSteamIds")
}

public 
CheckSteamIds(id)
{
    for(new 
1sizeof SteamIDsi++)
    {
        new 
szSteamID[32]
        
get_user_authid(idszSteamIDcharsmax(szSteamID))
        
        if(
equal(szSteamIDSteamIDs[i]))
        {
            
//Do stuff needed :)
        
}
    }

Never create a new variable inside a loop.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-04-2014 , 05:28   Re: if equal steamid
Reply With Quote #4

My bad, didn't know that one. Will update asap when I get home.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Old 06-07-2014, 04:17
CHE4TER
This message has been deleted by CHE4TER. Reason: error
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 06-07-2014 , 04:53   Re: if equal steamid
Reply With Quote #5

What's wrong in this menu?
If I'm ADMIN (ADMIN_BAN) the menu for ADMIN is displayed,
If I'm VIP (ADMIN_LEVEL_A) the menu for VIP is displayed,
If I'm USER (flag z no admin) the menu for users is displayed,

Well It's all ok, but if I'm the SteamID, the menu does not open, why?

PHP Code:
new const SteamIDs[][]=
{
    
"STEAM_x:x:xxxxxxxx",
    
"STEAM_y:y:yyyyyyyy"


PHP Code:
public sayMenu(id)
{
    new 
szString[64]
    new 
szFlags get_user_flags(id)

    new 
szSteamID[33]
    
get_user_authid(idszSteamIDcharsmax(szSteamID))
    for(new 
1sizeof SteamIDsi++)
    {
        if(
equal(szSteamIDSteamIDs[i]))
        {
            new 
menu menu_create("MENU FOR STEAMIDS""menuSteamIDS_handler")
            
menu_additem(menu"TEST""1")
            
menu_additem(menu"TEST""2")
            
menu_additem(menu"TEST""3")

            
menu_setprop(menuMPROP_EXITMEXIT_ALL)
            
menu_display(idmenu0)
        }
    }
    
// ADMIN
    
if(szFlags ADMIN)
        {
            new 
menu menu_create("MENU FOR ADMINS""menuAdmin_handler")
            
menu_additem(menu"TEST""1")
            
menu_additem(menu"TEST""2")
            
menu_additem(menu"TEST""3")
            
            
            
menu_setprop(menuMPROP_EXITMEXIT_ALL)
            
menu_display(idmenu0)
        }
    
// VIP
    
else if(szFlags VIP)
        {
            new 
menu menu_create("MENU FOR VIPS""menuVip_handler")
            
menu_additem(menu"TEST""1")
            
menu_additem(menu"TEST""2")
            
menu_additem(menuTEST"""3")
        
            
menu_setprop(menuMPROP_EXITMEXIT_ALL)
            
menu_display(idmenu0)
        }
    
// USER
    
else
        {
            new 
menu menu_create("MENU FOR USERS (NOT STEAMIDS/ADMIN/VIP = USER FLAG Z""userMenu_handler")
            
menu_additem(menu"TEST‚""1")
            
menu_additem(menu"TEST""2")
            
menu_additem(menu"TEST""3")
            
            
            
menu_setprop(menuMPROP_EXITMEXIT_ALL)
            
menu_display(idmenu0)
        }

CHE4TER is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-07-2014 , 05:52   Re: if equal steamid
Reply With Quote #6

Code:
for(new i = 1; i < sizeof SteamIDs; i++)
->
Code:
for(new i = 0; i < sizeof SteamIDs; i++)
__________________
Black Rose is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 06-07-2014 , 06:37   Re: if equal steamid
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
Code:
for(new i = 1; i < sizeof SteamIDs; i++)
->
Code:
for(new i = 0; i < sizeof SteamIDs; i++)
The menu for steamid still not opening
CHE4TER is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-07-2014 , 06:50   Re: if equal steamid
Reply With Quote #8

Does for me. (Apart from the missing handler, so it's actually not opened but at least I get an error.)
I can see that's not your actual code since it doesn't even compile.
Share the real code or figure it out yourself.
__________________

Last edited by Black Rose; 06-07-2014 at 06:53.
Black Rose is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 06-07-2014 , 11:55   Re: if equal steamid
Reply With Quote #9

Handler can be null. The menu must open if the code is ok

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define ADMIN        ADMIN_BAN
#define VIP        ADMIN_LEVEL_A

new const SteamIDs[][]=
{
    
"STEAM_",
    
"STEAM_"
}

public 
plugin_init() {
    
register_clcmd("say /menu""sayMenu")
}

public 
sayMenu(id

    new 
szString[64
    new 
szFlags get_user_flags(id

    new 
szSteamID[33
    
get_user_authid(idszSteamIDcharsmax(szSteamID)) 
    for(new 
1sizeof SteamIDsi++) 
    { 
        if(
equal(szSteamIDSteamIDs[i])) 
        { 
            new 
menu menu_create("MENU FOR STEAMIDS""menuSteamIDS_handler"
            
menu_additem(menu"TEST""1"
            
menu_additem(menu"TEST""2"
            
menu_additem(menu"TEST""3"

            
menu_setprop(menuMPROP_EXITMEXIT_ALL
            
menu_display(idmenu0
        } 
    } 
    
// ADMIN 
    
if(szFlags ADMIN
        { 
            new 
menu menu_create("MENU FOR ADMINS""menuAdmin_handler"
            
menu_additem(menu"TEST""1"
            
menu_additem(menu"TEST""2"
            
menu_additem(menu"TEST""3"
             
             
            
menu_setprop(menuMPROP_EXITMEXIT_ALL
            
menu_display(idmenu0
        } 
    
// VIP 
    
else if(szFlags VIP
        { 
            new 
menu menu_create("MENU FOR VIPS""menuVip_handler"
            
menu_additem(menu"TEST""1"
            
menu_additem(menu"TEST""2"
            
menu_additem(menu"TEST""3"
         
            
menu_setprop(menuMPROP_EXITMEXIT_ALL
            
menu_display(idmenu0
        } 
    
// USER 
    
else 
        { 
            new 
menu menu_create("MENU FOR USERS (NOT STEAMIDS/ADMIN/VIP = USER FLAG Z""userMenu_handler"
            
menu_additem(menu"TEST‚""1"
            
menu_additem(menu"TEST""2"
            
menu_additem(menu"TEST""3"
             
             
            
menu_setprop(menuMPROP_EXITMEXIT_ALL
            
menu_display(idmenu0
        } 
}

public 
menuSteamIDS_handler(idmenuitem)
{
}
public 
menuAdmin_handler(idmenu,item)
{
}
public 
menuVip_handler(idmenu,item)
{
}
public 
userMenu_handler(idmenu,item)
{

CHE4TER is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-07-2014 , 13:52   Re: if equal steamid
Reply With Quote #10

If the admin's SteamID is in the list, they will be shown two menus (the SteamID specific one and then the User one overwrites it).

Also, to improve efficiency, I would consider using a Trie for the SteamIDs. You will no longer need to use a loop to determine if they are in the list, it would change your loop to an if statement. This would make it easier solve the problem above because you could simply to else ifs for everything else.
__________________

Last edited by fysiks; 06-07-2014 at 13:54.
fysiks is offline
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

Forum Jump


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


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