Raised This Month: $ Target: $400
 0% 

equali & or


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
d4rkm3n
Junior Member
Join Date: Aug 2004
Old 12-17-2005 , 15:57   equali & or
Reply With Quote #1

hi

Code:
            if (equali(mapname,"cs_ || de_ || as_",3))             {                 server_cmd("echo blub do a cmd")             }

what is wrong about this code?
d4rkm3n is offline
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 12-17-2005 , 16:23  
Reply With Quote #2

Code:
    new mapname[64]     get_mapname(mapname,63)     if(containi(mapname,"cs_") != -1 || containi(mapname,"de_") != -1 || containi(mapname,"as_") != -1)     {         server_cmd("echo blub do a cmd")     }
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
d4rkm3n
Junior Member
Join Date: Aug 2004
Old 12-17-2005 , 17:07  
Reply With Quote #3

the server says:
Code:
changelevel failed: 'de_' not found on server


Code:
            new mapname2[4]             get_mapname(mapname2,3)             if(containi(mapname2,"cs_") != -1 || containi(mapname,"de_") != -1 || containi(mapname,"as_") != -1)             {                 server_cmd("changelevel %s",mapname)             }
d4rkm3n is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-17-2005 , 17:10  
Reply With Quote #4

Or, to stay consistent with what you were doing originally...
Code:
if (equali(mapname, "cs_", 3) || equali(mapname, "de_", 3) || equali(mapname, "as_", 3)) {    server_cmd("echo blub do a cmd") }
Brad is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 12-17-2005 , 17:11  
Reply With Quote #5

@atambo
your code will also print the echo if map name is: "dust_de_italy"

to check for first chars:
Code:
if (equali(mapname,"cs_",3) || equali(mapname,"de_",3) || equali(mapname,"as_",3) )
{
      server_cmd("echo blub do a cmd")
}

get_mapname(mapname2,3) :
will get the first 3 chars of a mapname
but have you ever seen a map called "de_" no its rather "de_dust"
so:
Code:
new mapname[33]
get_mapname(mapname, 32)
PS:
why you want to get mapname and change to that map ?
it is like the command : "restart"
__________________
alias White Panther
karlos is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-17-2005 , 17:12  
Reply With Quote #6

Your code doesn't work because you're creating the mapname variable with a length of 4. Try 32.

Presumably you have other problems too as you have mapname and mapname2 being used in this code snippet.
Brad is offline
d4rkm3n
Junior Member
Join Date: Aug 2004
Old 12-17-2005 , 17:28  
Reply With Quote #7

thank you guys! now it getting all clearer for me!
d4rkm3n is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-18-2005 , 04:31  
Reply With Quote #8

get_mapname returns the number of characters that you tell it to. If you tell it to get 3 characters, it will. You don't have to get all of it and limit the checking in equali.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-19-2005 , 15:11  
Reply With Quote #9

For those who don't know:
Code:
!containi(mapname, "cs_")
and
Code:
equali(mapname, "cs_", 3)
same things
VEN is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-19-2005 , 15:19  
Reply With Quote #10

No they aren't. The first could find "cs_" anywhere in the map name where as the second will only find it if the map name starts with "cs_". That's a big difference.

Totally made up map name: de_tics_assault

containi would erroneously think this is a "cs" map while equali would correctly identify it.
Brad 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 15:46.


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