AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unable to use on defuse/& other code questions (https://forums.alliedmods.net/showthread.php?t=75176)

KingCommentor 07-31-2008 18:06

Unable to use on defuse/& other code questions
 
Yes, I am trying to get into scripting starting off by editing others plugins, and this one kinda intrigued me, but there was a few things I didn't like. This specific Bazooka plugin doesn't allow users to buy bazookas on defusion maps, because of this line

PHP Code:

public handle_say(id) {
  new 
command[32]
  
read_argv(1command31)
  if (
equal(command"/buybazooka")) {
    if (
find_ent_by_class(-1"func_bomb_target") == 0) {
      if (
is_user_alive(id)) {
        if (
get_cvar_num("amx_bazooka_buyable") == 1) {
          
show_buymenu(id)
        }
        else {
          
client_print(idprint_
chat
"[Bazooka] The buymenu is disabled!")
        }
      }
      else {
        
client_print(idprint_chat"[Bazooka] You cannot buy a bazooka while you are dead!")
      }
    }
    else {
      
client_print(idprint_chat"[Bazooka] The bazooka is disabled on this map!")
    }
  } 

Do you mind explaining this? I get it partially, like if this is this, then this happens .. sorta .. I just dont complately understand the codeing, like "find_ent_by_class" .. whats that mean? And also, the entire command to together:
if (find_ent_by_class(-1, "func_bomb_target") == 0) {

Whats the -1 mean? .. Thats why I'm asking if you could just explain everything basicly .. that is in the code above.

AlsoWhat can be done to edit this to make it usable on defusion maps?
I tried taking it out complately but got a few error messages upon compiling.

I aslo tried just taking out only this line:
PHP Code:

if (find_ent_by_class(-1"func_bomb_target") == 0) { 

You get a compiling error 010: invalid function or declaration

Anyone know ?

KingCommentor 07-31-2008 18:09

Re: A few questions
 
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?

YamiKaitou 07-31-2008 18:18

Re: code questions
 
As per the Global Forum Rules, you need to have a descriptive topic. If you wish for this topic to stay open, please correct the topic title before you post again.


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

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