Raised This Month: $ Target: $400
 0% 

automatically selects the class


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PsychoPach
Member
Join Date: Aug 2010
Location: Lithuania
Old 08-14-2011 , 07:22   automatically selects the class
Reply With Quote #1

Hi all how make then you go in server and start play you automatically selects the class? and then you die you respawn and again auto class select. the class not the same, but different

CT 50% - that choose this class
Berserk 50% - that choose this class
Carmine 50% - that choose this class
Vox 50% - that choose this class
Girl 50% - that choose this class
Blade 50% - that choose this class
Robot 50% - that choose this class
Hellknight 50% - that choose this class

PHP Code:
/* Stay Alive Mod By Ziugis or PsychoPach. Special Thanks: Pur3Biatch, Exolent[jNr] */  

#include <amxmodx>    
#include <amxmisc>    
#include <fun>  
#include <cstrike>   
#include <fakemeta>  
#include <hamsandwich>   

#define PLUGIN "Stay Alive!"    
#define VERSION "0.1"    
#define AUTHOR "Ziugis"    

#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame 

enum _:CLASSES {     
    
CLASS_CT 0,    
    
CLASS_BERSERK,  
    
CLASS_CARMINE,  
    
CLASS_VOX,  
    
CLASS_GIRL,  
    
CLASS_BLADE,  
    
CLASS_ROBOT,  
    
CLASS_HELLKNIGHT  

new const 
className[CLASSES][] = { 
    
"CT"
    
"Berserk"
    
"Carmine"
    
"Vox"
    
"Girl"
    
"Blade"
    
"Robot"
    
"Hellknight" 
}; 
new 
Trie:classNameToIndex
enum _:MODELS 
    
MODEL_PLAYER
    
MODEL_WEAPON_P
    
MODEL_WEAPON_V 

new const 
classModels[CLASSES][MODELS][] = { 
    {
"CT"""""}, 
    {
"Berserk""""models/Alive/v_claws.mdl"}, 
    {
"Carmine""models/Alive/p_bak.mdl""models/Alive/v_bak.mdl"}, 
    {
"Vox""models/Alive/p_samurai.mdl""models/Alive/v_samurai.mdl"}, 
    {
"Girl""models/Alive/p_pockets.mdl""models/Alive/v_pockets.mdl"}, 
    {
"Blade""models/Alive/p_khanjar.mdl""models/Alive/v_khanjar.mdl"}, 
    {
"Robot""models/Alive/p_chainsaw.mdl""models/Alive/v_chainsaw.mdl"}, 
    {
"Hellknight"""""
}; 
// must untag (_:value) all floats, but keep the variable tagged as float 
// use _:-1.0 for damage to not alter the original damage 
new const Float:classDamage[CLASSES] = { 
    
_:-1.0_:70.0_:30.0_:60.0_:40.0_:40.0_:150.0_:100.0 
}; 
new const 
classHealth[CLASSES] = { 
    
5012002001501251507005000 
}; 
new const 
classArmor[CLASSES] = { 
    
100500250500050800
}; 
// must untag (_:value) all floats, but keep the variable tagged as float 
new const Float:classSpeed[CLASSES] = { 
    
_:400.0_:115.0_:300.0_:1000.0_:1500.0_:500.0_:450.0_:600.0 
}; 
new const 
classWeapons[CLASSES] = { 
    (
1<<CSW_M3), 
    (
1<<CSW_M249), 
    (
1<<CSW_MAC10)|(1<<CSW_TMP), 
    (
1<<CSW_MP5NAVY), 
    (
1<<CSW_M4A1), 
    (
1<<CSW_XM1014), 
    (
1<<CSW_AWP), 
    

}; 

new 
PlayerClass[33]   

new 
maxPlayers

public 
plugin_init()     
{    
    
register_plugin(PLUGINVERSIONAUTHOR)    
     
    
register_clcmd("say""CmdSay");   
     
    
RegisterHam(Ham_Item_Deploy"knife""FwdDeployKnifePost"1); 
    
RegisterHam(Ham_TakeDamage"player""KniveTakeDamage"); 
    
RegisterHam(Ham_Player_ResetMaxSpeed"player""FwdResetMaxSpeedPost"1); 
     
    
maxPlayers get_maxplayers(); 
}    

public 
plugin_precache()     
{   
    
classNameToIndex TrieCreate(); 
     
    new 
model[64]; 
    for(new class = 
0; class < CLASSES; class++) { 
        
copy(modelcharsmax(model), className[class]); 
        
strtolower(model); 
        
TrieSetCell(classNameToIndexmodel, class); 
         
        if(
classModels[class][MODEL_PLAYER][0]) { 
            
formatex(modelcharsmax(model), "models/player/%s/%s.mdl"classModels[class][MODEL_PLAYER], classModels[class][MODEL_PLAYER]); 
            
precache_model(model); 
        } 
        if(
classModels[class][MODEL_WEAPON_P][0]) { 
            
precache_model(classModels[class][MODEL_WEAPON_P]); 
        } 
        if(
classModels[class][MODEL_WEAPON_V][0]) { 
            
precache_model(classModels[class][MODEL_WEAPON_V]); 
        } 
    } 
     
    return 
PLUGIN_CONTINUE    


public 
CmdSay(id) { 
    new 
args[194]; 
    
read_args(argscharsmax(args)); 
    
remove_quotes(args); 
     
    if(
args[0] == '/') { 
        new 
command[32]; 
        
parse(args[1], commandcharsmax(command)); 
        
strtolower(command); 
         
        new class; 
        if(
TrieGetCell(classNameToIndexcommand, class) && PlayerClass[id] != class) { 
            
PlayerClass[id] = class; 
            
set_user_health(idclassHealth[class]); 
            
set_user_armor(idclassArmor[class]); 
            
set_user_maxspeed(idclassSpeed[class]); 
            if(
classModels[class][MODEL_PLAYER][0]) { 
                
cs_set_user_model(idclassModels[class][MODEL_PLAYER]); 
            } else { 
                
cs_reset_user_model(id); 
            } 
            new 
weaponName[20]; // weapon_smokegrenade = 19 
            
for(new CSW_P228<= CSW_P90i++) { 
                if(
classWeapons[class] & (1<<i) && get_weaponname(iweaponNamecharsmax(weaponName))) { 
                    
give_item(idweaponName); 
                } 
            } 
            
client_print(idprint_chat"[Stay Alive] You are %s now."className[class]); 
        } 
    } 


public 
FwdDeployKnifePost(weapon) { 
    new 
id pev(weaponpev_owner); 
     
    new class = 
PlayerClass[id]; 
     
    if(
classModels[class][MODEL_WEAPON_P][0]) { 
        
set_pev(idpev_weaponmodel2classModels[class][MODEL_WEAPON_P]); 
    } 
    if(
classModels[class][MODEL_WEAPON_V][0]) { 
        
set_pev(idpev_viewmodel2classModels[class][MODEL_WEAPON_V]); 
    } 


public 
FwdResetMaxSpeedPost(id) { 
    
set_user_maxspeed(idclassSpeed[PlayerClass[id]]); 


public 
KniveTakeDamage(victiminflictorattackerFloat:damagedamage_bits)   

    if(    
attacker == inflictor 
    
&&     attacker != victim 
    
&&     (<= attacker <= maxPlayers
    &&     
classDamage[PlayerClass[attacker]] >= 0.0 
    
&&     get_user_weapon(attacker) == CSW_KNIFE
    { 
        
SetHamParamFloat(4classDamage[PlayerClass[attacker]]); 
    } 

Or show the code how pleas
__________________
Sorry for me english

Last edited by PsychoPach; 08-14-2011 at 12:40.
PsychoPach is offline
Send a message via Skype™ to PsychoPach
Old 08-14-2011, 12:40
PsychoPach
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 09:29   Re: automatically selects the class
Reply With Quote #3

Just, sorry to interrupt, but just one question about it :
Code:
new const Float:classDamage[CLASSES] = {       _:-1.0, _:70.0, _:30.0, _:60.0, _:40.0, _:40.0, _:150.0, _:100.0   };

What is this :
Code:
_:

Thanks. Sorry ^^
__________________
Pawn ? Useless
Aooka is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-15-2012 , 11:46   Re: automatically selects the class
Reply With Quote #4

Quote:
Originally Posted by Aooka View Post
Just, sorry to interrupt, but just one question about it :
Code:
new const Float:classDamage[CLASSES] = {       _:-1.0, _:70.0, _:30.0, _:60.0, _:40.0, _:40.0, _:150.0, _:100.0   };

What is this :
Code:
_:

Thanks. Sorry ^^
In some instances the compiler will throw a warning when tags are used and _: will de-tag the value to eliminate the warning.
__________________
Bugsy is offline
Santaaa
BANNED
Join Date: May 2012
Old 07-15-2012 , 10:17   Re: automatically selects the class
Reply With Quote #5

Use random_num with cases

so for example

PHP Code:
new Number random_num(18)

switch (
Number)
{
    case 
1:
    case 
2:
    case 
3:
    case 
4:
    case 
5:
    case 
6:
    case 
7:
    case 
8:

Santaaa is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-15-2012 , 13:34   Re: automatically selects the class
Reply With Quote #6

Oh okay thanks Bugsy, so why here he do not write this symbol : ( _: )
Code:
new const classHealth[CLASSES] = {       50, 1200, 200, 150, 125, 150, 700, 5000   };   new const classArmor[CLASSES] = {       100, 500, 250, 500, 0, 50, 800, 0   };
__________________
Pawn ? Useless
Aooka is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-15-2012 , 13:46   Re: automatically selects the class
Reply With Quote #7

Probably because the array is not tagged with Float like the one above is.
__________________
Bugsy 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 03:19.


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