ID:168225
 
I was Wondering on How to make a verb or system on how do i make a way for somone who is donating power or hp points to the other person for a certain amount of time like say 5 mins or so and then it turns back to the owner of the power.

Thanks for the headstart
mob/verb/Lend(mob/M in view())
var/lending=switch(input(usr,"How much HP?","Lend") as num)
usr.hp-=lending
M.hp+=lending
sleep(500)
M.hp-=lending
usr.hp+=lending
In response to Mysame
Now i get this error when i define the proc switch

mob/proc/switch()


and i get

powerlend.dm:9:error:switch :invalid proc name: reserved word

Heres the coding

mob/verb/Lend(mob/M in view())
var/lending=switch(input(usr,"How much powerlevel?","Lend") as num)
usr.powerlevel-=lending
M.powerlevel+=lending
sleep(500)
M.powerlevel-=lending
usr.powerlevel+=lending
In response to Govegtos
Remove the switch proc from the input. When inputing a number, the switch proc is not neccesary.
In response to Kija
So like this

mob/verb/Lend(mob/M in view())
var/lending=(input(usr,"How much powerlevel?","Lend") as num)
usr.powerlevel-=lending
M.powerlevel+=lending
sleep(500)
M.powerlevel-=lending
usr.powerlevel+=lending


???
In response to Govegtos
Without the outer parenthesis.
In response to Govegtos
You might want to incorporate some factors such as not enough power to lend, or to give back.

mob/verb/Lend(mob/M in view())
var/lending=(input(usr,"How much powerlevel?","Lend") as num)
if(src.powerlevel>lending)
src.powerlevel-=lending
M.powerlevel+=lending
sleep(500)
if(M.powerlevel - lending < 0)
M << "You have given back all of then lent power, and you have none to spare!"
src.powerlevel += M.powerlevel
M.DeathCheck()
else
M.powerlevel -= lending
src.powerlevel+=lending
else
src << "You dont have enough power level to lend."
In response to Govegtos
Govegtos wrote:
Now i get this error when i define the proc switch

Considering switch wasn't a reserved word and all, what do you think defining mob/proc/switch() would have done? Especially if you kept it empty.
In response to Blakdragon77
No that'd still be buggy. What if one of the players log out? You'd have to mess have mob/Login() and call a proc for both players rather than continuing on in the verb.
In response to DeathAwaitsU
mob/Logout()
src.hp-= lending

In response to Mysame
Not really. We've only defined lending in a verb, not as a variable for mobs.

Plus mob/Logout() has problems.
In response to Govegtos
Programming by cookbook. Wonderful. *cough*
In response to DeathAwaitsU
Then it should be called in client/Del(), in a way that actually works. You could just have the proc check for the M.client, and if it's not there, you can load up the savefile and remove it from there, or just add it to the player and add the person's key that has logged out into a list. Check for the key upon client/New() or mob/Login() and take away the associated number from that user's powerlevel, and remove it from the list.