If you call an order like that it is treated just like a normal command and the console won't show it.metal_head wrote:Nope, withthe script didin't execute the "Give" order, I put "Give" in literals:Code: Select all
Give();
then the console showed that the "Give" order is being executed, but nothing changed, and there was no weapon swap.Code: Select all
self.think = "Give";
I'm sorry I haven't told this before, but I just realized there's a couple of things you need to do:
Set some kind of limit to the Q key. The player is likely to press it a lot longer than just for one frame. Right now it swaps the weapons each frame when Q is pressed, leading to the weapons being swapped many times really fast. You should make it so that it can only swap the weapons if the Q has been released since the last push. Like push -> swap once -> release -> push -> swap once. To do this you gotta add a new variable that tells if the key is pressed. I'll call it button_pressed. Then do these changes to the slot system script:
Code: Select all
if(IsKeyDown(14) and (button_pressed = false))
{
button_pressed = true;
Give();
}
if(IsKeyDown(14) = false)
{
button_pressed = false;
}
And the second thing:
It might be that you've already done this but I thought I'd mention it anyway. Does the slot system script change the player's weapon when the weapon is swapped? In other words, do you call the SetPlayerWeapon() command every frame or only when the player selects another weapon slot? If you don't get what I mean just post the script.
I'd approach this by creating an array with the weapon indices and the correct accessory names. And as I believe you haven't used arrays yet, here's a short introduction:metal_head wrote:Oh, and another question:
Once we're done with this, I'll have to visualize the guns swaping. I'm going to use thecommand, but how will the script know which of the weapon pawns (defined for atatchemnd in Pawn.ini) to use when for example the MY_WEAPON variable is 4.Code: Select all
AttachAccessory();
It's not possible to make it like the weapon arming:I'll have to make all the different accesory pawns responding to the different MY_WEAPON variable values, right? All I can think about for this is using "if" statements to check the different values of the MY_WEAPON variblae and then Remove the current accessory and add the new one, responding to the current MY_WEAPON value.Code: Select all
SetPlayerWeapon(GetAttribute("weapon2","Player"));
An array is defined like this:
Code: Select all
array_name
{
[item_0]
[item_1]
[item_2]
...
[item_n]
}
Code: Select all
array_name[item_number]
See where I'm getting at? You can link numbers with strings. And that's exactly what you need to do. You need to attach an accessory name (string) to each weapon index (number). So add something like this in the start of your script where the variables are defined:
Code: Select all
weaponarray
{
[accessory_pistol] //weapon index = 0
[accessory_shotgun] //weapon index = 1
[accessory_smg] //etc...
[accessory_assaultrifle]
[accessory_sniper]
}
Then you should be able to change the accessory with a single command:
Code: Select all
AttachAccessory(weaponarray[WEAPON]);