AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Skill points become negative (https://forums.alliedmods.net/showthread.php?t=347468)

stupid0303 04-28-2024 07:18

Skill points become negative
 
2 Attachment(s)
Parameters inside each_health 1
I changed it to each_health 5
There is only 1 skill point, and 5 parts can be deducted.
Skill points will become -4
How to solve it?

fysiks 04-28-2024 15:13

Re: Skill points become negative
 
If you need to just make sure that the value doesn't go below zero, you can add a check after every location that subtracts a value such as this:

PHP Code:

if( g_skills[id] < )
{
    
g_skills[id] = 0



stupid0303 04-28-2024 21:19

Re: Skill points become negative
 
Quote:

Originally Posted by fysiks (Post 2821748)
If you need to just make sure that the value doesn't go below zero, you can add a check after every location that subtracts a value such as this:

PHP Code:

if( g_skills[id] < )
{
    
g_skills[id] = 0





Thank you, boss
But after I modified it (modify the life part first)
If you click on it, there will be no response and the menu will be closed.

It has now been changed to
100 skill points will be deducted by 100 and will no longer be negative.
But the points need to be 0 to be displayed. There are not enough points.
If it is 1, the menu will be closed directly.

if(g_hp[id] >= 100)
{
client_printc(id, "\g血量已升至最高等級了!!!")
cmd_skills(id)
}
else
if(g_skills[id] >= 100)
{
g_skills[id] -= get_cvar_num("each_health")
g_hp[id] ++
cmd_skills(id)
}
else
if(!g_skills[id])
{
client_printc(id, "\g沒有足夠的技能點數")
cmd_skills(id)

fysiks 04-30-2024 22:59

Re: Skill points become negative
 
No idea what you just said.

stupid0303 04-30-2024 23:18

Re: Skill points become negative
 
Quote:

Originally Posted by fysiks (Post 2821861)
No idea what you just said.

If the remaining points are 0, client_printc(id, "\gThe blood volume has reached the highest level!!!")
If the remaining points are 1 or less than 100, click the skill and the menu will close.

Napoleon_be 05-02-2024 12:24

Re: Skill points become negative
 
It would be more helpful if you could just explain correctly what you're looking for. I would say it looks like chinese but your code is literally that.

fysiks already gave u the answer more or less on the "question" u asked.

PHP Code:

if(g_skills[id] < 0
{
    
g_skills[id] = 0;
    
// client_printc()
}

else if (
g_skills[id] < 100
{
    
// click skill & close menu?



stupid0303 05-02-2024 20:57

Re: Skill points become negative
 
Quote:

Originally Posted by Napoleon_be (Post 2821961)
It would be more helpful if you could just explain correctly what you're looking for. I would say it looks like chinese but your code is literally that.

fysiks already gave u the answer more or less on the "question" u asked.

PHP Code:

if(g_skills[id] < 0
{
    
g_skills[id] = 0;
    
// client_printc()
}

else if (
g_skills[id] < 100
{
    
// click skill & close menu?





PHP Code:

if(g_skills[id] >= //Click the skill point amount
{
g_skills[id] -= get_cvar_num("each_health")

}
else
if(
g_skills[id] < //If it is lower than this value, it will show that there are insufficient skill points and the menu will not disappear. 

Thank u
According to your method, no errors occurred when converting files.
Then I modified it myself and it was successful.

Bugsy 05-04-2024 11:18

Re: Skill points become negative
 
Quote:

Originally Posted by stupid0303 (Post 2821995)
PHP Code:

if(g_skills[id] >= //Click the skill point amount
{
g_skills[id] -= get_cvar_num("each_health")

}
else
if(
g_skills[id] < //If it is lower than this value, it will show that there are insufficient skill points and the menu will not disappear. 

Thank u
According to your method, no errors occurred when converting files.
Then I modified it myself and it was successful.

Chief, another option you have is using clamp()

val = clamp( the value , minimum , maximum )

val will always result in a value between min and max.


All times are GMT -4. The time now is 19:18.

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