weaponcommand - how gety accuraty weapon?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

weaponcommand - how gety accuraty weapon?

Post 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.......
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post 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.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post 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..!
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post 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:

Code: Select all

"models/weapons/kar98sniper.tik"
And not the way of assigning models to spawn script_models:

Code: Select all

"weapons/kar98sniper.tik"
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Post Reply