14.03.2013, 11:30
This is gonna look so nooby to most of you, but hey I am new to scripting. I am trying to make a command to buy a gun with a certain ammount of ammo.
I understand I need to use sscanf for this, and I've used it a couple of times in my script with no issue but this just isnt working, so I made a test command to try and understand how it works.
This is the code (sorry if it isnt posted correctly).
This is SUPPOSED to give the player a "colt" (id 22) with a specified ammount of ammo ("bullets").
However typing /testgun will just give the player a colt, with 0 ammo. (so it dissapears instantly I just see it flash up in the top right). No matter whether I type /testgun, /testgun colt 50, /testgun blahblahblah, the results are the same.
I'm missing something, and just cannot figure out what it is.
Any help with this would be greatly appreciated!
Thanks
I understand I need to use sscanf for this, and I've used it a couple of times in my script with no issue but this just isnt working, so I made a test command to try and understand how it works.
This is the code (sorry if it isnt posted correctly).
Код:
CMD:testgun(playerid,params[]){ if(IsPlayerInRangeOfPoint(playerid, 2, 295.8800,-38.5147,1001.5156)) { new gun; new bullets; if(sscanf(params, "coltd", gun, bullets)) return givePlayerValidWeapon(playerid, 22, bullets); } return 1; }
However typing /testgun will just give the player a colt, with 0 ammo. (so it dissapears instantly I just see it flash up in the top right). No matter whether I type /testgun, /testgun colt 50, /testgun blahblahblah, the results are the same.
I'm missing something, and just cannot figure out what it is.
Any help with this would be greatly appreciated!
Thanks