AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   What's wrong with my code? (https://forums.alliedmods.net/showthread.php?t=20439)

Major_victory 11-08-2005 15:10

What's wrong with my code?
 
hello all, second post, woot!

anywho i have aproblem here, i've been doing alot of tweaking with other ppl's scripts and learning quite a bit, however i've been trying to add a restrict feature to the bazooka mod plugin by More. so far i've managed to get this

Code:

public forward_playerprethink(id) {
  if (is_user_alive(id)) {
    new weaponid, clip, ammo
    weaponid = get_user_weapon(id, clip, ammo)
    if ((weaponid == CSW_C4) && hasBazooka[id]) {
      new attack = get_user_button(id) & IN_ATTACK
      new oldattack = get_user_oldbutton(id) & IN_ATTACK
      new attack2 = get_user_button(id) & IN_ATTACK2
      new oldattack2 = get_user_oldbutton(id) & IN_ATTACK2
      new moderestrict = get_cvar_num("amx_bazooka_restrict")

      if (attack && !oldattack) {
        if (CanShoot[id] && allow_shooting && (user_controll[id] == 0)) {
          fire_rocket(id)
        }
      }
      else if (attack2 && !oldattack2) {
        switch(mode[id]) {
          case 1: {
                if (moderestrict==1)
                {
                mode[id] = 1
                client_print(id, print_center, "Other modes are restricted")
                }
                else
                {
                mode[id] = 2
                }
                client_print(id, print_center, "Switched to heat-seeking mode")
          }
          case 2: {
                  if (moderestrict==1)
                {
                mode[id] = 1
                client_print(id, print_center, "Other modes are restricted")
                }
                else
                {
                mode[id] = 3
                }
                client_print(id, print_center, "Switched to user-guided mode")
          }
          case 3: {
                  if (moderestrict==1)
                {
                mode[id] = 1
                client_print(id, print_center, "Other modes are restricted")
                }
                else
                {
                mode[id] = 1
                }
                client_print(id, print_center, "Switched to normal mode")
          }
        }
      }       
}

this seems to be the section where when the player presses secondary fire it changes the mode. what i want it to do is read the cvar "amx_bazooka_restrict" and determine wheter or not you can switch modes.
It seems logically sound and compiles without any errors but it just simply doesn't work.
here's his post if you want the plugin:
http://forums.alliedmods.net/showthread.php?p=72047

on a side note i think the cvar only takes effect if it was set before the server was created. i want to be able to turn it on and off in realtime.

another side note, i asked a while ago if he could make an amx_bazooka_give function for that plugin, well... i don't need it now, i already did it :P
not bad for my first week of scripting eh?

v3x 11-08-2005 15:25

Code:
public client_PreThink(id) {   // }

Major_victory 11-08-2005 16:27

okay i'll try that later tonight... i don't have time to test it right now..

Progress:
I just finished putting team colors on the smoke trails the rockets make, andi changed the sounds a tiny bit, plus lots of other tweaks and fun stuffs.

later all

XxAvalanchexX 11-08-2005 19:31

v3x, my guess is that forward_playerprethink is a FM hook, though I don't know why you wouldn't use client_PreThink.

v3x 11-08-2005 21:44

I was thinking that as well, but was too lazy to find out :)

Major_victory 11-09-2005 12:27

yeah, well the code isn't mine, i'm just modifying it so i can learn how things work :P

I tested the code last night and it works perfectly, i just had to modify a few more things so it didn't always say "switched to heat-seeking mode" when the other modes were restricted.

thx for your help guys


All times are GMT -4. The time now is 23:43.

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