AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how?: execute once on mapchange (https://forums.alliedmods.net/showthread.php?t=20278)

Riddick51 11-05-2005 12:36

how?: execute once on mapchange
 
here is what i want to do:

only 1 time, after map change:
Code:
    new mapname[24]     new tmapn[4]     get_mapname(mapname, 23)     copy(tmapn,3,mapname) . . .     if (tmapn=="de_")       //test for defuse map type         //execute this code

Hawk552 11-05-2005 12:39

Code:
// ... new bool:mapthing; // ... // ... checkmap("de_"); // ... public checkmap(arg[]) {     new mapname[64];     get_mapname(mapname,63);     if(containi(mapname,arg)!=-1)     {         mapthing = true;     }     return 0; }

EDIT:

Code:
public whatever_func() {     if(mapthing == true)     {         // do stuff     }     //...

Riddick51 11-05-2005 15:44

Yes, Hawk, that got the job done --- Thanks a Mil! ;o

Xanimos 11-05-2005 15:55

Why do so much if he only wants to execute this code once?

Code:
public plugin_init() {     //...    set_task(0.1 , "CheckMap") } public CheckMap() {     new mapname[4]     get_mapname(mapname, 3)     if(!equali(mapname, "de_"))         return PLUGIN_HANDLED    //Put code here }

its simplier and has less variables. so uses less memory.

Yours has two functions and 3 variables(1 global). and this one has one function and one variable. with less code doing the same thing.

v3x 11-05-2005 15:57

I usually do that stuff in plugin_cfg()

Hawk552 11-05-2005 19:51

He can always just modify it to not use variables, and if he needs it more than once, my method is better. Come on, seriously, what would be the extra CPU and overhead? 0.0000001 for the split second it takes to calculate that, and maybe a few bytes.

Riddick51 11-05-2005 20:47

my solution involved combining elements from Hawk and Suicid3. The code was forwarded to BAILOPAN to be included in CSDM2.


All times are GMT -4. The time now is 23:39.

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