AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Const reading problem (https://forums.alliedmods.net/showthread.php?t=252907)

Estland 12-11-2014 10:28

Const reading problem
 
Code:

#include <amxmodx>

new const g_maps[][] =
{
  "de_inferno",
  "de_dust2"
}

public plugin_init(){
  register_plugin("Drop Awp","0.3","Faval")
  register_event("WeapPickup","Kontroll","b","1=18")
  return PLUGIN_CONTINUE
}

public Kontroll(id) {
  new map[32]
  get_mapname(map, 31)
  for(new i=0;i< sizeof(g_maps);i++)
  {
      if(equal(map, g_maps[i]))
      {
        return PLUGIN_CONTINUE
      }
      new llama = read_data(0)
      client_print(llama,print_center,"AWP pole lubatud.")
      engclient_cmd(llama, "drop","weapon_awp")
      client_cmd(llama,"drop weapon_awp")
      return PLUGIN_CONTINUE
  }
  return PLUGIN_HANDLED
}

My problem is that it reads the first map fine, but mapnames after that aren't read by the plugin.

HamletEagle 12-11-2014 10:43

Re: Const reading problem
 
Code:
#include <amxmodx> new const g_maps[][] = {    "de_inferno",    "de_dust2" } public plugin_init(){    register_plugin("Drop Awp","0.3","Faval")    register_event("WeapPickup","Kontroll","b","1=18") } public Kontroll(id) {    new map[32]    get_mapname(map, charsmax(map))    for(new i=0;i< sizeof g_maps;i++)    {       if(equal(map, g_maps[i]))       {          continue       }       new llama = read_data(0)       client_print(llama,print_center,"AWP pole lubatud.")       engclient_cmd(llama, "drop","weapon_awp")       client_cmd(llama,"drop weapon_awp")    } }
You should learn how to use and when to use return.

Estland 12-11-2014 12:34

Re: Const reading problem
 
Now it doesn't work at all. If map is included in g_maps list, then I want the player to be able to pick up the AWP.

jimaway 12-11-2014 13:11

Re: Const reading problem
 
Quote:

Originally Posted by Estland (Post 2234009)
Now it doesn't work at all. If map is included in g_maps list, then I want the player to be able to pick up the AWP.

why wont you just use the restmenu plugin that comes with amxx counter-strike addon pack?

Estland 12-11-2014 14:17

Re: Const reading problem
 
User wants to control restriction through this plugin's sma.

It still works only with the first map. Why? :/

HamletEagle 12-11-2014 14:25

Re: Const reading problem
 
Now I think that I understood what you need.

Code:
#include <amxmodx> new const g_maps[][] = {     "de_inferno",     "de_dust2" } new bool: AllowOnThisMap public plugin_init(){     register_plugin("Drop Awp","0.3","Faval")         new map[32]     get_mapname(map, charsmax(map))     for(new i=0;i< sizeof g_maps;i++)     {         if(equal(map, g_maps[i]))         {             AllowOnThisMap = true             break         }     }     if(!AllowOnThisMap)     {         register_event("WeapPickup","Kontroll","b","1=18")     }     else     {         pause("a")     } } public Kontroll(id) {     new llama = read_data(0)     client_print(llama,print_center,"AWP pole lubatud.")     engclient_cmd(llama, "drop","weapon_awp")     client_cmd(llama,"drop weapon_awp") }


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

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