Raised This Month: $ Target: $400
 0% 

Unable to use on defuse/& other code questions


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
KingCommentor
Senior Member
Join Date: Jan 2008
Location: Floridaaaa
Old 07-31-2008 , 18:09   Re: A few questions
Reply With Quote #2

Also, I wrote this small script as my first plugin and there were a few errors, here is the orignial code:

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)
  }
 }


And then after a few suggestions .. I changed a bit around and it now looks like this.. and works fine.

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
  } 
 } 

I don't understand what was done.. since I just pasted in the suggestions, whats this actually doing?
PHP Code:
Gravity currently costs %d!" , tprice 
I know its getting the price set on the cvar, but .. what EXACTLY is it doing .. the t? Whats it for?
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?
__________________
+Karma is appreciated! |Be PROUD, leave your name!

Last edited by KingCommentor; 07-31-2008 at 19:29.
KingCommentor is offline
Send a message via AIM to KingCommentor
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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