Page 1 of 1
weaponcommand - how gety accuraty weapon?
Posted: Sat Dec 20, 2008 7:51 pm
by Aprop
I want get actual ai/player weapon accuracy, and set id to 50% of default value. Its possible? Then "after some time" set it to 25%, and back to 100. Is it possible? I never used weap'com' before, so im a bit inexperienced.......
Posted: Sat Dec 20, 2008 9:01 pm
by $oldier Of Ra
I'm afraid weaponcommand can only set values and not return any

If a player hasn't edited his weapon tik files then the accuracy of all weapons remains the same. For AI weapons (they're the same as player weapons), their accuracy stays the same no matter what skill is set. However the AI's accuracy can be different according to the skill or script-set accuracy setting.
Posted: Tue Dec 23, 2008 10:48 am
by Aprop
Maybe its possible to get name of weapon which player use at the moment?
but accuracy of all weapons arent the same, i think springfield and m1 garand have bigger accuracy than mp40, etc..!
Posted: Tue Dec 23, 2008 11:43 am
by $oldier Of Ra
No, I meant if no one has messed with the accuracy, the accuracy of example: the springfield will be the same in every server and in LAN.
Getting the name through the statefiles is easy but through scripting is a bit harder but I think you'll understand. We must firstly need to cast commands to the weapon therefor we need the targetname:
Code: Select all
<player_alias> weaponcommand dual targetname ("w" + self.entnum)
So $wX is the name of our weapon. X is a variable depending on the entnum of your player. We don't need to know X since the entnum doesn't change in the same server.
Now to check if he is holding a weapon and if so then give that weapon's model a variable of the player:
Code: Select all
// simplify
local.weapon = $("w" + self.entnum )
// if the player is holding a weapon:
if(local.weapon != NULL)
{
// the model of the current weapon is being assigned to an entity variable
// now you can retrieve this in other scripts
<player_alias>.weapon = local.weapon.model
// to prevent errors
local.weapon targetname ""
}
// else give him an unarmed.tik model because he isn't holding anything
else
{
<player_alias>.weapon = "models/weapons/unarmed.tik"
}
Check for the .weapon variable on the player. That will hold the model of the weapon the player is using. It's the full model name in a string. Example:
And
not the way of assigning models to spawn script_models: