AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bind variable into command ? (https://forums.alliedmods.net/showthread.php?t=65380)

AlexanderM 01-07-2008 10:14

Bind variable into command ?
 
1 Attachment(s)
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 ?

purple_pixie 01-07-2008 10:27

Re: Bind variable into command ?
 
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"?

AlexanderM 01-07-2008 10:38

Re: Bind variable into command ?
 
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 :D

Yourl find yourself in the credit section, think it's off something you
posted for a couple of years ;P

purple_pixie 01-07-2008 10:42

Re: Bind variable into command ?
 
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.


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

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