Raised This Month: $ Target: $400
 0% 

Solved set_user_maxspeed with level


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
1M1e
Member
Join Date: Mar 2020
Old 07-23-2021 , 17:02   set_user_maxspeed with level
Reply With Quote #1

hi,

i tried to make who in level 5 he will get speed

For zombie 20
for human 50
but it dose not work

can someone tell me whats the problem?

Code:
#include <zombie_escape>
#include <crxranks>
#include <fun>
 
#define ITEMS1 5
 
public plugin_init()
{
    register_plugin("[ZE] Bonus With Level", "0.1", "whatever")
    register_event("HLTV", "new_round", "a", "1=0", "2=0");
}

public new_round()
{
    set_task(1.0, "BonusLevel")
}
 
public BonusLevel(id)
{
	if(ze_is_user_zombie(id))
	{
		if(crxranks_get_user_level(id) == ITEMS1)
		{
			set_user_maxspeed(id, get_user_maxspeed(id) +20)
		}
	}
	else
	{
		if(crxranks_get_user_level(id) == ITEMS1)
		{
			set_user_maxspeed(id, get_user_maxspeed(id) +50)
		}
	}
    
	return 1;
}

Last edited by 1M1e; 07-25-2021 at 02:28.
1M1e is offline
lexzor
Senior Member
Join Date: Nov 2020
Old 07-23-2021 , 17:19   Re: set_user_maxspeed with level
Reply With Quote #2

the values must be float

20 -> 20.0
50 -> 50.0
lexzor is offline
Old 07-23-2021, 17:35
1M1e
This message has been deleted by 1M1e.
1M1e
Member
Join Date: Mar 2020
Old 07-23-2021 , 17:36   Re: set_user_maxspeed with level
Reply With Quote #3

Quote:
Originally Posted by lexzor View Post
the values must be float

20 -> 20.0
50 -> 50.0
Did not work
1M1e is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-23-2021 , 18:53   Re: set_user_maxspeed with level
Reply With Quote #4

Max speed resets everytime you switch weapon, hook CurWeapon event.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-23-2021 , 20:48   Re: set_user_maxspeed with level
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
Max speed resets everytime you switch weapon, hook CurWeapon event.
Ham_CS_Player_ResetMaxSpeed or Ham_Item_PreFrame would be better.
__________________
+ARUKARI- is online now
1M1e
Member
Join Date: Mar 2020
Old 07-24-2021 , 06:58   Re: set_user_maxspeed with level
Reply With Quote #6

Like this?

Code:
#include <zombie_escape>
#include <crxranks>
#include <fun>
 
#define ITEMS1 5
 
public plugin_init()
{
    register_plugin("[ZE] Bonus With Level", "0.1", "whatever")
    register_event("HLTV", "new_round", "a", "1=0", "2=0");
}

public new_round()
{
    set_task(1.0, "BonusLevel")
}

public BonusLevel(id)
{
	if(ze_is_user_zombie(id))
	{
		if(crxranks_get_user_level(id) >= ITEMS1)
		{
			
			static Float:flMaxSpeed
			
			get_entvar(id, var_maxspeed, flMaxSpeed)
			
			set_entvar(id, var_maxspeed, flMaxSpeed + 20.0)
			set_user_maxspeed(id, get_user_maxspeed(id) +20.0)
		}
	}
	else
	{
		if(crxranks_get_user_level(id) >= ITEMS1)
		{
			static Float:flMaxSpeed
			
			get_entvar(id, var_maxspeed, flMaxSpeed)
			
			set_entvar(id, var_maxspeed, flMaxSpeed + 50.0)
			set_user_maxspeed(id, get_user_maxspeed(id) +50.0)
		}
	}
    
	return 1;
}

Last edited by 1M1e; 07-24-2021 at 06:58.
1M1e is offline
+ARUKARI-
AlliedModders Donor
Join Date: Jul 2004
Location: Japan
Old 07-24-2021 , 08:24   Re: set_user_maxspeed with level
Reply With Quote #7

PHP Code:
RegisterHam(Ham_Item_PreFrame"player""BonusLevel"1); 
__________________

Last edited by +ARUKARI-; 07-24-2021 at 08:25.
+ARUKARI- is online now
1M1e
Member
Join Date: Mar 2020
Old 07-24-2021 , 12:14   Re: set_user_maxspeed with level
Reply With Quote #8

Quote:
Originally Posted by +ARUKARI- View Post
PHP Code:
RegisterHam(Ham_Item_PreFrame"player""BonusLevel"1); 
Thanks its work now

final code

Code:
#include <zombie_escape>
#include <crxranks>
#include <fun>

#define ITEM5 5
#define ITEM10 10
 
public plugin_init()
{
    register_plugin("[ZE] Bonus With Level", "0.1", "whatever")
    RegisterHam(Ham_Item_PreFrame, "player", "BonusLevel", 1); 
}
public BonusLevel(id)
{
	if(ze_is_user_zombie(id))
	{
		return 1;
	}
	else
	{
		if(crxranks_get_user_level(id) == ITEM5)
		{
			set_user_maxspeed(id, get_user_maxspeed(id) +10.0)
		}
		
		else if(crxranks_get_user_level(id) >= ITEM10)
		{
			set_user_maxspeed(id, get_user_maxspeed(id) +20.0)
		}
	}

	return 1;
	
}

Last edited by 1M1e; 07-26-2021 at 14:11.
1M1e 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 02:16.


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