Raised This Month: $ Target: $400
 0% 

Bind variable into command ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlexanderM
Junior Member
Join Date: Dec 2007
Old 01-07-2008 , 10:14   Bind variable into command ?
Reply With Quote #1

Hi.

Im a litle new, begining to understand some of the code, but still new to amx modx.

In my plugin I want to tell the client wich 'class' he is. My plugin is kinda
giant so ill just post som of the code in PHP.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
 
#define CLASS_NOTHING 0     
#define CLASS_WARLOCK 1
#define CLASS_MAGE 2
#define CLASS_WARRIOR 3
#define CLASS_ROUGE 4
 
public plugin_init() 
{
         
register_clcmd("say showclass""ShowChar")
 
}
public 
ShowChar(id) {            
 
 if ( 
PlayerClass[id] == CLASS_NOTHING) {    
 
  
Change(id)
 
  
set_hudmessage(0255255, -1.0, -1.006.012.0)   
  
show_hudmessage(id"[WOW] You haven't choosen a class !")
 
  return 
PLUGIN_HANDLED;          
 
         }
 if ( 
PlayerClass[id] == CLASS_WARLOCK) { 
 
            
set_hudmessage(0255255, -1.0, -1.006.012.0)
            
show_hudmessage(id"[WOW] You are a Warlock !")
 
            return 
PLUGIN_HANDLED;
 
        }   
        if ( 
PlayerClass[id] == CLASS_MAGE) { 
 
            
set_hudmessage(0255255, -1.0, -1.006.012.0)
            
show_hudmessage(id"[WOW] You are a Mage !")
 
            return 
PLUGIN_HANDLED;
 
        }   
        if ( 
PlayerClass[id] == CLASS_WARRIOR) { 
 
            
set_hudmessage(0255255, -1.0, -1.006.012.0)
            
show_hudmessage(id"[WOW] You are a Warrior !")
 
            return 
PLUGIN_HANDLED;
 
        }   
        if ( 
PlayerClass[id] == CLASS_ROUGE) { 
 
            
set_hudmessage(0255255, -1.0, -1.006.012.0)
            
show_hudmessage(id"[WOW] You are a Rouge !")
 
            return 
PLUGIN_HANDLED;
        }
 return 
PLUGIN_HANDLED;

This is kinda huge, and I have 9 classes, so coulden't I make this another way ?
Attached Files
File Type: sma Get Plugin or Get Source (tbc_mod.sma - 602 views - 68.5 KB)
__________________
Uhm... More Pizza...
______________________________
| Home | Search | Google | Steam |

Last edited by AlexanderM; 01-07-2008 at 10:41. Reason: Posted the .sma file ;P
AlexanderM is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 01-07-2008 , 10:27   Re: Bind variable into command ?
Reply With Quote #2

Sort of like:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
 
#define CLASS_NOTHING 0     
#define CLASS_WARLOCK 1
#define CLASS_MAGE 2
#define CLASS_WARRIOR 3
#define CLASS_ROUGE 4

new const CLASS_NAMES[5][]=
{
	"No Class",
	"Warlock",
	"Mage",
	"Warrior",
	"Rogue"
}
 
public plugin_init() 
{
         register_clcmd("say showclass", "ShowChar")
 
}
public ShowChar(id) {            
    
 if ( PlayerClass[id] == CLASS_NOTHING) {    
            
  Change(id)
  
  set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)   
  show_hudmessage(id, "[WOW] You haven't choosen a class !")
            
  return PLUGIN_HANDLED;          
            
         }
 new message[64] ;
 format(message,sizeof message-1,"[WOW] You are a  %s !",CLASS_NAMES[PlayerClass[id]])
 set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
 show_hudmessage(id, message)
 return PLUGIN_HANDLED;
}
?

And by "kinda giant" do you mean "straight from the tutorial"?
purple_pixie is offline
AlexanderM
Junior Member
Join Date: Dec 2007
Old 01-07-2008 , 10:38   Re: Bind variable into command ?
Reply With Quote #3

No, I can post it if you want to se it. But you are warned...
Ive just begined to make something new stuff, so I haven't
made any comments, and checked... Looks so crappy :S

Think it's about 70 kb, well it's big for atleast me.

Thanks for the help

Yourl find yourself in the credit section, think it's off something you
posted for a couple of years ;P
__________________
Uhm... More Pizza...
______________________________
| Home | Search | Google | Steam |

Last edited by AlexanderM; 01-07-2008 at 10:42.
AlexanderM is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 01-07-2008 , 10:42   Re: Bind variable into command ?
Reply With Quote #4

Yeah, 30 K is pretty big for a plugin.
Well, for a small plugin.

I think my half-completed Class-based plugin's about 69 KB.
purple_pixie 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 11:13.


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