AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need help with 2 plugins (https://forums.alliedmods.net/showthread.php?t=11947)

Belsebub 04-01-2005 15:18

need help with 2 plugins
 
im working on 2 plugins now and i got some problems, on the classes plugin the resethud thing dont seem work and on the stats plugin i get theese errors when i compile:

Code:

(9) : error 017: undefined symbol "id"
(9 -- 10) : error 008: must be a constant expression; assumed zero

the stats plugin:

Code:
 //----------------------------------------------------------------------------------------------  #include <amxmodx>  #include <amxmisc>  #include <engine>  #include <fun>  //----------------------------------------------------------------------------------------------  // VARIABLES  new constitution[33] = 1  new hp[33] = 10 * (constitution[id])  new pointsleft[33] = 5  //----------------------------------------------------------------------------------------------  public plugin_init()  {     register_plugin("Stats", "1.0", "Belsebub")     register_menucmd(register_menuid("Stats Menu"), 1023, "ActionMenu")     register_clcmd("say /statsmenu", "ShowMenu", -1, "Shows The stats menu")     register_event("ResetHUD", "Event_Resethud", "a")  }  //----------------------------------------------------------------------------------------------  public ShowMenu(id)  {     new szMenuBody[256]     new keys     new len = format( szMenuBody, 255, "Stats Menu:^nPoints Left:%d^n",pointsleft )     len += format( szMenuBody[len], 255-len, "^n\w1. Constitution (%d)",constitution )     len += format( szMenuBody[len], 255-len, "^n\w2. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w3. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w4. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w5. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3|1<<4)     show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public ActionMenu(id, key)  {     switch(key)     {         case 0:         {             constitution[id] += 1             pointsleft[id] -= 1         }         case 1:         {             return PLUGIN_CONTINUE         }         case 2:         {             return PLUGIN_CONTINUE         }         case 3:         {             return PLUGIN_CONTINUE         }         case 4:         {             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public Event_Resethud(id)  {     if (constitution[id] == 1) {         return PLUGIN_CONTINUE     }     new health = get_user_health ( id )     set_user_health(id, health + hp[id])     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------

the classes plugin:

Code:
 //----------------------------------------------------------------------------------------------  #include <amxmodx>  #include <amxmisc>  #include <fun>  #include <cstrike>  //----------------------------------------------------------------------------------------------  // VARIABLES  new bool:Sniper[33] = false  new bool:Engineer[33] = false  new bool:Medic[33] = false  new bool:NoClass[33] = true  //----------------------------------------------------------------------------------------------  public plugin_init()  {     register_plugin("Classes","0.1","Belsebub")     register_event("ResetHUD", "Event_Resethud", "a")     register_menucmd(register_menuid("Class Menu:"),1023,"ActionMenu")     register_clcmd("say /changeclass","ShowMenu")  }  //----------------------------------------------------------------------------------------------  public Event_Resethud(id)  {     if (NoClass[id] == true)  {         ShowMenu(id)         return PLUGIN_CONTINUE         } else if (Sniper[id] == true) {         set_user_maxspeed(id, 320.0)         give_item(id, "weapon_scout")         set_user_footsteps(id,1)         } else if (Engineer[id] == true) {         set_user_health(id,150)         } else if (Medic[id] == true) {         set_user_health(id,200)     }     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public ShowMenu(id)  {     new szMenuBody[512]     new keys     new len = format(szMenuBody, 511, "\yClass Menu:^n" )     len += format( szMenuBody[len], 511-len, "^n\w1. Sniper" )     len += format( szMenuBody[len], 511-len, "^n\w2. Engineer" )     len += format( szMenuBody[len], 511-len, "^n\w3. Medic" )     len += format( szMenuBody[len], 511-len, "^n\w4. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3)     show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_CONTINUE  }  //--------------------------------------------------------------------------------------------  public ActionMenu(id,key)  {     switch(key)     {         case 0:         {             Sniper[id] = true             Engineer[id] = false             Medic[id] = false             NoClass[id] = false         }         case 1:         {             Sniper[id] = false             Engineer[id] = true             Medic[id] = false             NoClass[id] = false         }         case 2:         {             Sniper[id] = false             Engineer[id] = false             Medic[id] = true             NoClass[id] = false         }         case 3:         {             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------

Belsebub 04-06-2005 08:44

cant anyone help me?

Ced 04-06-2005 09:35

Code:
new hp[33] = 10 * (constitution[id])
This cannot be done since id is not known at the time u declare this variable.

And try changing the flag to "b" on the resethud

Belsebub 04-06-2005 09:39

ty, and then what to change the [id] to?

Ced 04-06-2005 09:54

just declare
Code:
new hp[33]
and then put
Code:
hp[id] = 10 * constitution[id]
before u set the hp

XxAvalanchexX 04-06-2005 14:25

Quote:

Code:
hp[id] = 10 * constitution[id]

Why do you want players to gain advantages by joining the game at different times? This is a really odd and stupid equation.

Belsebub 04-06-2005 14:29

what?

Belsebub 04-07-2005 10:17

still have problems with the resethud event and in the stats plugin it doesn't add 1 to constitution if i choose that in the menu and doesn't remove 1 pointsleft, and i replaced the hp[id] = 10 * constitution[id] thing with a switch

new stats plugin:
Code:
 //----------------------------------------------------------------------------------------------  #include <amxmodx>  #include <amxmisc>  #include <engine>  #include <fun>  //----------------------------------------------------------------------------------------------  // VARIABLES  new constitution[33] = 0  new pointsleft[33] = 5  //----------------------------------------------------------------------------------------------  public plugin_init()  {     register_plugin("Stats", "1.0", "Belsebub")     register_menucmd(register_menuid("Stats Menu"), 1023, "ActionMenu")     register_clcmd("say /statsmenu", "ShowMenu", -1, "Shows The stats menu")     register_event("ResetHUD", "Event_Resethud", "b")  }  //----------------------------------------------------------------------------------------------  public ShowMenu(id)  {     if (pointsleft[id] == 0) {         client_print(id, print_center, "[AMXX] You Have 0 Stat Points Left.")         return PLUGIN_CONTINUE     }     new szMenuBody[256]     new keys     new len = format( szMenuBody, 255, "Stats Menu:^nPoints Left:%d^n",pointsleft )     len += format( szMenuBody[len], 255-len, "^n\w1. Constitution (%d)",constitution )     len += format( szMenuBody[len], 255-len, "^n\w2. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w3. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w4. Nothing" )     len += format( szMenuBody[len], 255-len, "^n\w5. Exit" )     keys = (1<<0|1<<1|1<<2|1<<3|1<<4)     show_menu( id, keys, szMenuBody, -1 )     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public ActionMenu(id, key)  {     switch(key)     {         case 0:         {             constitution[id] += 1             pointsleft[id] -= 1             set_task ( 0.2, "ShowMenu", id )         }         case 1:         {             set_task ( 0.2, "ShowMenu", id )         }         case 2:         {             set_task ( 0.2, "ShowMenu", id )         }         case 3:         {             set_task ( 0.2, "ShowMenu", id )         }         case 4:         {             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------  public Event_Resethud(id, constitution)  {     new health = get_user_health ( id )     switch(constitution)     {         case 1:         {             set_user_health(id, health + 10)         }         case 2:         {             set_user_health(id, health + 20)         }         case 3:         {             set_user_health(id, health + 30)         }         case 4:         {             set_user_health(id, health + 40)         }         case 5:         {             set_user_health(id, health + 50)         }     }     return PLUGIN_CONTINUE  }  //----------------------------------------------------------------------------------------------

v3x 04-07-2005 14:46

Code:
constitution[id]++ pointsleft[id]--
Shouldn't that do the same thing?


All times are GMT -4. The time now is 09:49.

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