AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   first "plugin", scripting errors? (https://forums.alliedmods.net/showthread.php?t=75004)

KingCommentor 07-28-2008 20:46

first "plugin", scripting errors?
 
PHP Code:

#include <amxmisc>
#include <cstrike>
#include <fakemeta_util>
 
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
 
new price
new enabled
new g_MsgSync
 
public plugin_init() 
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_clcmd("say /test","testing")
 
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(idg_MsgSync,"TESTING EXECUTED")
   
fm_user_gravity(id,0.25
   
cs_set_user_money(idmoney-price)
  }
 }


When compiling I get this error:
test.sma<35> : error 017:undefined symbol "fm_user_gravity"

Which is here
Code:

fm_user_gravity(id,0.25)
Whats the problem ?

atomen 07-28-2008 21:21

Re: first "plugin", scripting errors?
 
It's supposed to be fm_set_user_gravity.
But you should use "set_pev(id, pev_gravity, 0.25);" and replace fakemeta utility with fakemeta.

KingCommentor 07-28-2008 21:35

Re: first "plugin", scripting errors?
 
What is the difference from what I had to what you suggested?

Well with the addition from above the plugin compiles and works .. sort of.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
 
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
 
new price
new enabled
new g_MsgSync
 
public plugin_init() 
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_clcmd("say /grav","testing")
 
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(idg_MsgSync,"Your gravity is now 400")
   
set_pev(idpev_gravity0.50)
   
cs_set_user_money(idmoney-price)
  }
 }


When ingame and I type /grav I DO get 400 gravity like its suppose to, the HUD does appear BUT inseatd of just taking away the $1000 cost ..it minuses like 1.8Million.
What causes this ?
---
Also how can I make it so when you buy /grav you keep it until you die?
Also could you tell me what the code is to keep it forever/until map change?

ALSO just found out none of my cvars work .. ?

danielkza 07-29-2008 01:14

Re: first "plugin", scripting errors?
 
To get a cvar's value you must use get_pcvar_(num/float/string),not use the plain value. Knowing this, the line:
Code:

cs_set_user_money(id, money-price)
must be:
Code:

cs_set_user_money(id, money - get_pcvar_num(price))

Bugsy 07-29-2008 09:28

Re: first "plugin", scripting errors?
 
The below 2 lines should both be using the cvar 'price' you created to detect the price you have gravity set to. I added the adjustment in the below code. I also added to your chat display advising the user the current cost of gravity if they did not have enough $.

if (money < 1000)
.....
cs_set_user_money(id, money-price)

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
 
#define PLUGIN "TESTING"
#define VERSION "1.0"
#define AUTHOR "kingcommentor"
 
new price
new enabled
new g_MsgSync
 
public plugin_init() 
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_clcmd("say /grav","testing")
 
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)
 new 
tprice get_pcvar_num(price);
 if (
get_pcvar_num(enabled) == 1)
 {
  if (
money tprice)
  {
   
client_print(id,print_chat,"You don't have enough money! Gravity currently costs %d!" tprice)
  }
  else
  {
   
set_hudmessage(01272550.300.2906.0,15.0)
   
ShowSyncHudMsg(idg_MsgSync,"Your gravity is now 400")
   
set_pev(idpev_gravity0.50)
   
cs_set_user_money(idmoney-tprice)
  }
 }



KingCommentor 07-29-2008 10:18

Re: first "plugin", scripting errors?
 
I don't unnderstand what you did, whats this mean?

PHP Code:

%d!" , tprice) 


and
PHP Code:

 if (money tprice

PHP Code:

cs_set_user_money(idmoney-tprice

what exactly is this doing that what I had before isn't?


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

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