AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   equali & or (https://forums.alliedmods.net/showthread.php?t=22056)

d4rkm3n 12-17-2005 15:57

equali & or
 
hi

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

what is wrong about this code?

atambo 12-17-2005 16:23

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")     }

d4rkm3n 12-17-2005 17:07

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)             }

Brad 12-17-2005 17:10

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") }

karlos 12-17-2005 17:11

@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"

Brad 12-17-2005 17:12

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.

d4rkm3n 12-17-2005 17:28

thank you guys! now it getting all clearer for me!

XxAvalanchexX 12-18-2005 04:31

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.

VEN 12-19-2005 15:11

For those who don't know:
Code:
!containi(mapname, "cs_")
and
Code:
equali(mapname, "cs_", 3)
same things

Brad 12-19-2005 15:19

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.


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

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