Raised This Month: $12 Target: $400
 3% 

new round keeps hp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-27-2022 , 16:26   new round keeps hp
Reply With Quote #1

hello, Im trying to make a human classes and i was wondering how could i let a player having the same "class" more rounds? i mean, if a player chooses class1 (200hp blabla) but he is able to chose only one class per round, how can i let him continuing the same class even the next round without choosing it again?
PHP Code:
public evHookRoundStart( )
{
    new 
iPlayers32 ];
    new 
iPlayersNum;
    
    
get_playersiPlayersiPlayersNum"ch" );        
    for( new 
iPlayersNum i++ )
    {
        
UserChoosed[iPlayers[i]]  =  false;
    }
    

i have to false the userchoosed to make it work once a round... but i want to let the player keeping the class even in the next round and only next round to be able to change his class! (only if he wants, he can keep the same class every round without having to choose every round)
edit: the main thing i want is that if i choose class1 with 200hp the next round i want to respawn with 200hp again (as my class) not default with 100
__________________
a simple act of caring creates an endless ripple.

Last edited by Nutu_; 08-27-2022 at 16:35.
Nutu_ is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-27-2022 , 17:58   Re: new round keeps hp
Reply With Quote #2

You can define the HP in an enum for each class and then set each accordingly with set_user_health on that hook roundstart.
__________________
deprale is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-27-2022 , 19:15   Re: new round keeps hp
Reply With Quote #3

Quote:
Originally Posted by deprale View Post
You can define the HP in an enum for each class and then set each accordingly with set_user_health on that hook roundstart.
could you send me an example please?
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-27-2022 , 23:16   Re: new round keeps hp
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>

new gChosenClass[MAX_PLAYERS+1]


enum _:Classes
{
    
szClassName[64],
    
iSetHealth
}

new const 
g_Classes[ ][ Classes ] = {
    {
"BATMAN"1555},
    {
"HUMAN"200},
    {
"ZOMBIE"1004},
    {
"TAKTU"9999}
}

public 
plugin_init(){
    
register_plugin("test""0.0.1""none");
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1
}

public 
fwHamPlayerSpawnPost(id){
    if (!
is_user_connected(id))
        return 
PLUGIN_HANDLED


    gChosenClass
[id] = // TEMPORARY (You should build your own menu for selection, this is solely for demonstrative purposes)

    
switch(gChosenClass[id]){
        case 
0grant(id0)
        case 
1grant(id1)
        case 
2grant(id2)
        case 
3grant(id3)
    }

    return 
PLUGIN_HANDLED;
}

stock grant(idint){
    
set_user_health(idg_Classesint ][ iSetHealth ])
    
client_print(idprint_center"Your class is %s"g_Classes[int][szClassName])

I didn't build a menu since I don't have the time to build one for this demo.
__________________

Last edited by deprale; 08-27-2022 at 23:16. Reason: forgot the code tags
deprale is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 08-28-2022 , 05:21   Re: new round keeps hp
Reply With Quote #5

1st, i want to add more than just hp, speed and gravity too..
2nd, do i have to use spawnpost because i dont want to show the menu everyround to a player..
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 08-28-2022 , 14:29   Re: new round keeps hp
Reply With Quote #6

Quote:
Originally Posted by Nutu_ View Post
1st, i want to add more than just hp, speed and gravity too..
2nd, do i have to use spawnpost because i dont want to show the menu everyround to a player..
Of course you don't have to use spawnpost, and you can just add iSetSpeed and iSetGravity in the enum, then set them in the g_Classes array after the HP, it's scalable! I used spawnpost because it was easier for my example, exactly why I didn't build a whole menu for the demo.

PHP Code:
enum _:Classes
{
    
szClassName[64],
    
iSetHealth,
    
iSetSpeed,
    
iSetGravity
}

new const 
g_Classes[ ][ Classes ] = {
    {
"BATMAN"1555450600}, // This is poor hardcoding practice, I'd suggest defining the classes speed & gravity for each one, so you can easily change them after. #define CLASS_SPEED int #define CLASS_GRAVITY int
    
{"HUMAN"200250800}, // And use them instead of these 'hardcoded' values here, will be more readable and better in long term.
    
{"ZOMBIE"1004500700},
    {
"TAKTU"99991001000}

^ This is poor hardcoding practice, I'd suggest defining the classes speed & gravity for each one, so you can easily change them after.
__________________

Last edited by deprale; 08-28-2022 at 14:34.
deprale is offline
Reply


Thread Tools
Display Modes

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 18:33.


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