AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compile errors (https://forums.alliedmods.net/showthread.php?t=74966)

KingCommentor 07-28-2008 01:09

Compile errors
 
I wrote this plugin just now as my first ever to see if I could do it, but I got compiling errors but don't know how to read them/learn from them.
Does anyone know why this happened?


Code:

#include <amxmodx>
#include <amxmisc>
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
new money
new gravity
new price
new enabled
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /test","testing")
money = cs_get_user_money(id)
gravity = register_cvar("amx_gravity", "0.25")
price = register_cvar("amx_grav_price", "1000")
enabled = register_cvar("amx_grav_enabled", "1")
}
public testing(id)
{
 if (get_pcvar_num(enabled) == 1)
 {
  if (Money < 1000)
    {
    client_print(id,print_chat,"You don't have enough money!")
    }
    else
    {
    client_print(id, print_chat, "TESTING EXECUTED")
    set_user_gravity(id,(gravity))
    cs_set_user_money(id, money-price)
    }
 }
}

Also how can I make the message appear in the middle of the players screen instead of down where teh chat is .. and also how can I make it appear as a HUD ?

scrtxxcaz 07-28-2008 01:34

Re: Compile errors
 
try this...

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
new gravity
new price
new enabled
new g_MsgSync
public plugin_init() 
{
     
register_plugin(PLUGINVERSIONAUTHOR)
      
register_clcmd("say /test","testing")
      
gravity register_cvar("amx_gravity""0.25")
      
price register_cvar("amx_grav_price""1000")
      
enabled register_cvar("amx_grav_enabled""1")
      
g_MsgSync CreateHudSyncObj()
}
public 
testing(id)

      new 
money cs_get_user_money(id)
      if (
get_pcvar_num(enabled) == 1)
      {
            if (
money 1000)
            {
                  
client_print(id,print_chat,"You don't have enough money!")
            }
            else
            {
                  
set_hudmessage(01272550.300.2906.0,15.0)
                  
ShowSyncHudMsg(0g_MsgSync,"TESTING EXECUTED")
                  new 
Float:grav get_pcvar_float(gravity)
                  
set_user_gravity(id,grav)
                  
cs_set_user_money(idmoney-price)
            }
      }


PHP Code:

set_user_gravity(id,graivty

would compile with a tag mismatch error

KingCommentor 07-28-2008 01:40

Re: Compile errors
 
Code:

/home/groups/amxmodx/tmp3/phpLibAIS.sma(15) : warning 217: loose indentation
Header size:            464 bytes
Code size:              940 bytes
Data size:              604 bytes
Stack/heap size:      16384 bytes; estimated max. usage=175 cells (700 bytes)
Total requirements:  18392 bytes
 
1 Warning.
Done.

The compiling works but it gets a file open error when you start the sever .. I am new to scripting .. what did you do could you please explain it ?

Also what else can be done to fix this ?

scrtxxcaz 07-28-2008 01:58

Re: Compile errors
 
Basically you had to include cstrike because you are using functions from that module ex: cs_get_user_money(id). you have to include fun because you are using a function from that module ex: set_user_gravity(id,grav).

You had money = get_user_money(id) in the plugin_init() function but that function is called when the plugin starts and doesnt pass player id's. Then since u register a cvar as a float u must get it as a float and save it to a variable that is a float.... new Float:grav = get_pcvar_float(gravity).

I hope I explained that so u can understand what i mean...

KingCommentor 07-28-2008 02:11

Re: Compile errors
 
Whats Float mean though?
And could you better explain the HUD you added please?

And also the plugin gets a file open error, what is the problem ?

scrtxxcaz 07-28-2008 02:43

Re: Compile errors
 
Show the error your server is getting please.

A float is a number with a decimal bascially like 20.0 or 20.983

Sorry i forgot about the HUD. Here is a link that will explain the use of CreateHudSyncObj and ShowSyncHudMsg better then i can http://www.amxmodx.org/funcwiki.php?...cObj&go=search. Then you must set_hudmessage() which is a function used to format your hud message http://www.amxmodx.org/funcwiki.php?...sage&go=search. AMXX studio has a hudmessage generator that will automatically set the numbers. Then finally show the HUD message by using ShowSyncHudMsg http://www.amxmodx.org/funcwiki.php?...dMsg&go=search.

Hope this helps.

KingCommentor 07-28-2008 14:41

Re: Compile errors
 
There isnt really an error, the only thing the console says it "Plugin file open error."

But when compiling I get these errors with this code:
PHP Code:

/home/groups/amxmodx/tmp3/phpaYfhqt.sma(16) : error 017undefined symbol "id"
/home/groups/amxmodx/tmp3/phpaYfhqt.sma(32) : warning 213tag mismatch
 
1 Error
.
Could not locate output file /home/groups/amxmodx/public_html/websc3/phpaYfhqt.amx (compile failed 

How do you read and understand these? Can someone explain how to read a compiling error if its not blatently shown whats wrong.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
new money
new gravity
new price
new enabled
 
public plugin_init() 
{
register_plugin(PLUGINVERSIONAUTHOR)
register_clcmd("say /test","testing")
money cs_get_user_money(id)
gravity register_cvar("amx_gravity""0.25")
price register_cvar("amx_grav_price""1000")
enabled register_cvar("amx_grav_enabled""1")
}
 
public 
testing(id)
{
 if (
get_pcvar_num(enabled) == 1)
 {
   if (
money 1000)
    {
    
client_print(id,print_chat,"You don't have enough money!")
    }
    else
    {
    
client_print(idprint_chat"TESTING EXECUTED")
    
set_user_gravity(id,gravity
    
cs_set_user_money(idmoney-price)
    }
 }




Also I found that if you space these out like this, i get a whole nother list of compiling errors, do they have to be all together?
Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
 
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"


scrtxxcaz 07-28-2008 15:17

Re: Compile errors
 
No they dont have to be together. Also the placement of money = cs_get_user_money(id) is in the wrong place.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
new gravity
new price
new enabled
new g_MsgSync
public plugin_init() 
{
      
register_plugin(PLUGINVERSIONAUTHOR)
      
register_clcmd("say /test","testing")
      
//move money = cs_get_user_money(id) to testing(id)
      
gravity register_cvar("amx_gravity""0.25")
      
price register_cvar("amx_grav_price""1000")
      
enabled register_cvar("amx_grav_enabled""1")
      
g_MsgSync CreateHudSyncObj()
}
public 
testing(id)

      new 
money cs_get_user_money(id//must be here to get the players money..cannot be in plugin_int. It will not get the players
      
if (get_pcvar_num(enabled) == 1)
      {
            if (
money 1000)
            {
                  
client_print(id,print_chat,"You don't have enough money!")
            }
            else
            {
                  
set_hudmessage(01272550.300.2906.0,15.0)
                  
ShowSyncHudMsg(0g_MsgSync,"TESTING EXECUTED")
                  new 
Float:grav get_pcvar_float(gravity//must get the cvar as a float and save as a float
                  
set_user_gravity(id,grav)  //if variable is not a float you will get a tag mismatch error here
                  
cs_set_user_money(idmoney-price)
            }
      }



KingCommentor 07-28-2008 15:32

Re: Compile errors
 
How do I know when/where do make it a "float"
And why does money have to be in "Testing"?

I put it in plugin.init because I was telling it what "money means" since its a nick for cs_get_user_money(id)

PHP Code:

new money cs_get_user_money(id

Why did you put new beside that?

minimiller 07-28-2008 15:32

Re: Compile errors
 
EDIT: Faaaaaar too late


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

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