ID:142840
 
Recently I have added a skill point system to a game i run and i noticed a little bug it gives whoever u award skill points to 150 but for some reason the players can keep using the points even after they zero out. my friend and I have Both looked over the code for the points but we cant find the bug can anyone help out

If you're using someone else's source code, then no, we can't help. You'll have to figure it out on your own.

If its a problem in YOUR code, then just check wherever it takes points away and make it cancel the function if they have less than the required points available.
Sorry forgot about the code

mob
var/skill_points
verb
Spend_Skill_Points()
switch(input(usr,"Distribute Points","[src.skill_points] remaining",text) in list ("Health","Reiatsu","Attack","Defense","Reiatsu Power"))
if("Health")mhealth += input("How many points do you want to use on health","[src.skill_points] remaining",text)as num
if("Reiatsu")mrei += input("How many points do you want to use on reiatsu","[src.skill_points] remaining",text)as num
if("Attack")attack += input("How many points do you want to use on attack","[src.skill_points] remaining",text)as num
if("Defense")defence += input("How many points do you want to use on defence","[src.skill_points] remaining",text)as num
if("Reiatsu Power")reiatsu += input("How many points do you want to use on reiatsu power","[src.skill_points] remaining",text)as num
if(skill_points > 0 && skill_points <= src.skill_points)
src.skill_points -= skill_points

src <<"You now have [src.skill_points] points"

here is the verb for it

mob
verb
GM_Help()
switch(input("This will send an alert to all GMs, if you use this verb without reason you will be punished. Are you sure you want to use this verb?", text) in list ("Yes","No"))
if("Yes")
var/msg=input("What do you want to say?","Alert")as text
for(var/mob/M in world)
if(M.GM)
M << "<font color = lime>ALERT: [usr] has alerted us and the reason is [msg]!"

and here is the var

var/tmp/Spend_Skill_Points //(put this ne where)
view=8
random
tmp/skill_points

sorry im not that great at posting here
In response to Wrath69
There's a reason for the auto-layout in this board... but anyhow.

if("Health")mhealth += input("How many points do you want to use on health","[src.skill_points] remaining",text)as num


This means "If they choose Health, add their inputted number to mhealth. Fullstop." - you don't even check if they have enough skill_points!

Only at the end, AFTER you've given them the bonus, do you attempt to take away skill_points.

if(skill_points > 0 && skill_points <= src.skill_points)
src.skill_points -= skill_points


If they have more than 0 skill_points, take away the skill_points (which is like say "take x away from x") else, don't bother.

Very randomly pieced together piece of code, really, and the admin verb (stolen???) is nothing to do with it.

~Ease~
In response to Ease
Ty Ease