AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Performing multiple commands in an if/then statement (https://forums.alliedmods.net/showthread.php?t=52814)

ELEVENNNN 03-20-2007 01:55

Performing multiple commands in an if/then statement
 
Hey.. Trying to get some help with the following code... (line 17) if(!invis[id]) I want to use get_user_weapon (i think) or whatever command I would need to determine if they are using a knife... so:

if invis is exec'd and the weapon is knife then perform the following functions:


Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <cstrike>
 
new bool:invis[33]
 
public plugin_init()
{
    register_plugin("mod","1.0","author")
    register_clcmd("goinvis","hook_goinvis")
}
 
public hook_goinvis(id)
{
    if(!invis[id])
    {
        invis[id]=true
        set_task(5.0,"un_invis",id)
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
        client_print(id, print_chat, "You are now invisable.")
        set_user_footsteps(id, 1)
    }
  return PLUGIN_HANDLED
}
 
public un_invis(id)
{
    invis[id]=false
    set_user_rendering(id)
    client_print(id, print_chat, "You are now visible again.")
    set_user_footsteps(id, 0)
}

How would we go about doing that, thanks everyone who answers in advanced

-Kurt

[ --<-@ ] Black Rose 03-20-2007 05:15

Re: Performing multiple commands in an if/then statement
 
new temp;
if ( ! invis[id] && get_user_weapon(id, temp, temp) == CSW_KNIFE )

v3x 03-20-2007 05:16

Re: Performing multiple commands in an if/then statement
 
hopefully this helps:
Code:

public hook_goinvis(id)
{
        if(!is_user_alive(id)) // check if the player is dead
        {
                // obviously so
                return PLUGIN_HANDLED;
        }

        new clip, ammo, weapid = get_user_weapon(id, clip, ammo);

        if(!invis[id] && weapid == CSW_KNIFE) // check if the player isn't invisible & has his knife out
        {
                invis[id] = true;

                set_task(5.0, "un_invis", id);
                set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 0);
                set_user_footsteps(id, 1);

                client_print(id, print_chat, "You are now invisible.");
        }

        return PLUGIN_HANDLED;
}

off to bed:?

jopmako 03-20-2007 05:23

Re: Performing multiple commands in an if/then statement
 
Code:

#include <amxmodx>
//#include <amxmisc>
#include <fun>
//#include <engine>
#include <cstrike>
 
new bool:invis[33]
 
public plugin_init()
{
    register_plugin("mod","1.0","author")
    register_clcmd("goinvis","hook_goinvis")
    register_event("CurWeapon", "even_CurWeapon", "be", "1=1")
}
 
public hook_goinvis(id)
{
    if(!invis[id])
    {
        invis[id]=true
        engclient_cmd(id,"weapon_knife")
        set_task(5.0,"un_invis",id)
        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,0)
        client_print(id, print_chat, "You are now invisable.")
        set_user_footsteps(id, 1)
    }
    return PLUGIN_HANDLED
}
 
public un_invis(id)
{
    invis[id]=false
    set_user_rendering(id)
    client_print(id, print_chat, "You are now visible again.")
    set_user_footsteps(id, 0)
}
 
public even_CurWeapon(id)
{
  if (invis[id] && read_data(2)!=CSW_KNIFE)
  {
      engclient_cmd(id,"weapon_knife")
  }
}

player only can use knife when invisable.

ELEVENNNN 03-20-2007 06:21

Re: Performing multiple commands in an if/then statement
 
Thanks you much, that worked with a small amount of tweaking. much thanks

-Kurt


All times are GMT -4. The time now is 11:14.

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