ID:264160
 
Code:
        Give_Attack(mob/M as mob in world)
set name = "Give Attack"
set category = "God"
set desc = "Give a player any attack verb"
var/varAttack
var/varVerb = input("Are you sure?","Checking") in list("Proceed","Cancel")
if(varVerb == "Cancel")
return
if(varVerb == "Proceed")
varAttack = input("What Attack?","Attack Verb") in typesof(/mob/Attacks/verb/) + list("Cancel")
if(varAttack == "Cancel")
return
varAttack += M.verbs
if(M.GM >=1)
world<<"<b><center>[usr] has given [M] an <i>Attack</i> Verb."
else
return


Problem description:
It doesn't give the verb they selected out. Can anyone help me so that it does?
1. There's no point in having GM verbs show for normal players. A method of having verbs show only for certain players is shown in the DM Guide.

2. You have an if statement for "Cancel" twice.

3. Look at the else if statement in the DM Reference. Using multiple if() statements makes multiple resource-consuming checks.

4. For boolean checking, use if(variable) for a true value, and if(!variable) for a false(empty string, null, 0) value.

5. You're adding the mob's verbs to the varAttack variable, when it should be the other way around.
In response to Glarfugus
In fact, 'else' is actually unneeded because the if() above has return, meaning it will only ever process the code below if that if() did not execute. But he really shouldn't use a "Cancel" list item anyway: 1) It's usually better looking and more convenient to make those kind of things with alert() instead - it's simpler and works for up to 3 buttons. 2) If you want a cancel option with input(), simply specify 'null' as an input type, combining with other input types as needed with the | operator. This creates a Cancel button next to the OK button, which causes the input() proc to return null if clicked. For choosing from a list, you do:
input("") as null|anything in List


Also, it probably still won't work after fixing 5), if I remember correctly, input() had quirks with verb paths, it returns null when one is selected, even though it displays them fine. The workaround is to use text strings instead (and in turn, text2path() later on). I wonder if the Staff is aware of this or not...
In response to Kaioken
I think they are. I heard somewhere that verbs aren't meant to be accessed by clients or something like that. Either way, it would be hard to not know of the problem, as someone makes a post on it every month or so.
In response to Jeff8500
Month? Gotta be more often than that. ;P But I'd have thought they'd fix it if they're aware of it. Maybe it's just in Danland, then. It does actually display the proc paths correctly, but it returns null, very buglike, and this shouldn't be the case. Yes of course, there is always using a workaround with the arguments such as text strings instead, using an altogether different method than input(), etc...