Raised This Month: $ Target: $400
 0% 

Performing multiple commands in an if/then statement


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ELEVENNNN
Junior Member
Join Date: Mar 2007
Old 03-20-2007 , 01:55   Performing multiple commands in an if/then statement
Reply With Quote #1

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

Last edited by ELEVENNNN; 03-20-2007 at 02:18.
ELEVENNNN is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-20-2007 , 05:15   Re: Performing multiple commands in an if/then statement
Reply With Quote #2

new temp;
if ( ! invis[id] && get_user_weapon(id, temp, temp) == CSW_KNIFE )
[ --<-@ ] Black Rose is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-20-2007 , 05:16   Re: Performing multiple commands in an if/then statement
Reply With Quote #3

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
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
jopmako
Senior Member
Join Date: Jul 2006
Location: QQ:331537639
Old 03-20-2007 , 05:23   Re: Performing multiple commands in an if/then statement
Reply With Quote #4

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.
__________________
QQ31537639
jopmako is offline
Send a message via MSN to jopmako
ELEVENNNN
Junior Member
Join Date: Mar 2007
Old 03-20-2007 , 06:21   Re: Performing multiple commands in an if/then statement
Reply With Quote #5

Thanks you much, that worked with a small amount of tweaking. much thanks

-Kurt
ELEVENNNN is offline
Reply



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 02:30.


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