View Full Version : Some scripting problems [noob question]
Sorry for bothering with this stupid questions, but..
I made a very, very simple script that adds weapons and ammo to any character in-game. It's like that:
Quote[/b] ]this addMagazine "30Rnd_545x39_AK"
this addMagazine "30Rnd_545x39_AK"
this addWeapon "AK74"
exit
But when the character runs it, he only gets the AK without any ammo. Can anyone help me? http://forums.bistudio.com/oldsmileys/huh.gif
Thanks.
Sorry for bothering with this stupid questions, but..
I made a very, very simple script that adds weapons and ammo to any character in-game. It's like that:
Quote[/b] ]this addMagazine "30Rnd_545x39_AK"
this addMagazine "30Rnd_545x39_AK"
this addWeapon "AK74"
exit
But when the character runs it, he only gets the AK without any ammo. Can anyone help me? http://forums.bistudio.com/oldsmileys/huh.gif
Thanks.
this addweapon "AK74"; this addMagazine "30Rnd_545x39_AK"
You have to put this on your units init field. If you use it in another context you have to replace "this" with your units name.
But I put "[this] exec "ak74.sqs" in the init field of the units I want to give the AK. They all get the AK, but no ammo. I suppose "this" in the script is replaced by the unit which is executing it, right?
Anyway, thanks for the help. I'll check it out.
addweapon command has always have to be placed before the addmagazine command to make it work.
Edit: Oh make sure you start with RemoveAllWeapons this before trying adding new weapons
addweapon command has always have to be placed before the addmagazine command to make it work.
Edit: Oh make sure you start with RemoveAllWeapons this before trying adding new weapons
No, you are wrong about the placement, although a removeallweapons this certainly helps from manually removing the other mags/weapons.
But you can put addmagazine and should put addmagazine before addweapon. This is because if you put addweapon afterwards, you have to reload. Oh, and makesure to use this at the end.
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this switchweapon primaryweapon this[/QUOTE]
Anyways, back to the original dismayimafy.
Quote[/b] ]But I put "[this] exec "ak74.sqs" in the init field of the units I want to give the AK. They all get the AK, but no ammo. I suppose "this" in the script is replaced by the unit which is executing it, right?
Anyway, thanks for the help. I'll check it out.
Exec your script like this
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">This exec "Ammoscript.sqs"[/QUOTE]
Use this script:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
removeallweapons _this
_this addMagazine "30Rnd_545x39_AK"
_this addMagazine "30Rnd_545x39_AK"
_this addWeapon "AK74"
_this selectweapon (primaryweapon _this)
exit[/QUOTE]
Thanks, MrZig, ir worked. http://forums.bistudio.com/oldsmileys/thumbs-up.gif
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.