ID:175351
 
Im trying to make it so when you have the item Pistol_Clips that you can add more ammo to your Pistol but the coding i tried wont work. Here's what i tried:
obj
clips
Pistol_Clips
verb
Add_Ammo()
set src in usr.contents
if(locate(/obj/guns/Pistol in usr.contents))
locate(/obj/guns/Pistol in usr.contents).clips += 10//error on this line

But i get the error:
Gun.dm:49:error: .: expected end of statement


Please help me fix this problem. If im completely wrong with my code how can i change it so it will work? THanks in advance!
You can't use the . or : operators directly after something in parentheses like that. You have to assign the locate() result to a var first, then use that. I'd try it like this:
var/obj/guns/Pistol/G = locate() in usr
G.clips += 10

Lummox JR
In response to Lummox JR
k thanks ill try that, it worked! thanks!!!!!!!!!!!!!!!