Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2013-01-25 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
January 24, 2013, 07:06:05 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Weapons not being given on spawn  (Read 315 times)
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« on: November 29, 2012, 09:32:07 PM »

Anyone have any ideas why one of my races is sometimes not giving out weapons?

Sometimes it does, sometimes it doesn't.  This is the code:

Code:
new String:WeaponChance[25][] = {"weapon_knife", "weapon_glock", "weapon_usp", "weapon_p228", "weapon_deagle", "weapon_elite", "weapon_fiveseven", "weapon_m3", "weapon_xm1014", "weapon_galil", "weapon_ak47", "weapon_scout", "weapon_sg552", "weapon_awp", "weapon_g3sg1", "weapon_famas", "weapon_m4a1", "weapon_aug", "weapon_sg550", "weapon_mac10", "weapon_tmp", "weapon_mp5navy", "weapon_ump45", "weapon_p90", "weapon_m249"};

public GambleWeapons(client)
{
new skill_weps = War3_GetSkillLevel( client, thisRaceID, SKILL_WEPS );
weaponGive = GetRandomInt(0,(skill_weps*2));
new String:temp[64] = "weapon_knife,weapon_c4,";
StrCat(temp, 64, WeaponChance[weaponGive]);
War3_WeaponRestrictTo( client,thisRaceID, temp);
CreateTimer(2.5,giveWeapon,client);
PrintToChat(client, "\x04 This round you will use %s", WeaponChance[weaponGive]);

}

public Action:giveWeapon(Handle:timer,any:client)
{
GivePlayerItem( client, WeaponChance[weaponGive]);
}

I'm not getting any errors, just sometimes it doesn't give the weapon...  Any ideas appreciated!  I thought putting the timer in before giving the wep would help, but it hasn't.
Logged
Revan
Sr. Member
****
Posts: 346



View Profile
« Reply #1 on: November 29, 2012, 11:49:29 PM »

The symbol "weaponGive" is undefined in the context of the "giveWeapon" timer callback. you need to recalculate it.

Aside from this there should be realy no problem in using GiveItemPlayer directly on player_spawn I think(not 100% sure)
Logged

#war3source
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #2 on: November 30, 2012, 01:45:13 AM »

weaponGive is initialised outside of both these functions, it works fine.  Most of the time the player gets the weapon fine, just every now and then they don't ...
Logged
Revan
Sr. Member
****
Posts: 346



View Profile
« Reply #3 on: November 30, 2012, 12:45:11 PM »

Does the message appear in the chat(and contains the correct weapon)? or does it just won't show up when weapon was not given?
Logged

#war3source
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #4 on: November 30, 2012, 02:40:51 PM »

The message appears with a weapon every time.  MOST of the time, the player is then given that weapon.  It seems to happen irrespective of team.

I don't know if this is quite true, but at least it appears that if a person has not been given a weapon once, they are more likely to not be given it again.

I'll try moving the chat message into the timer function for now, to see if that is being triggered every time.

Thanks for your help.
Logged
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #5 on: December 01, 2012, 11:52:53 PM »

The problem only seems to happen when there are multiple players playing on this race.  Even then it doesn't happen EVERY time, but it seems that once you stop getting a weapon, you then no longer get a weapon!

Is it possible for the timers to be conflicting?
Logged
Revan
Sr. Member
****
Posts: 346



View Profile
« Reply #6 on: December 02, 2012, 10:50:55 AM »

Nope, but take a look at weaponGive.
It's a global variable, you set it on GambleWeapons() and give the weapon with a delay. But in the 2.5 seconds weapon give delay another call to GambleWeapons may happen, so you need to make sure it's the proper value.
3 ways to make sure it's the correct value:
  • datatimer
  • make a MAXPLAYERCUSTOM array
  • just recalculate 'weaponGive'
« Last Edit: December 02, 2012, 10:53:04 AM by Revan » Logged

#war3source
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #7 on: December 02, 2012, 02:10:55 PM »

Thanks Revan.  I'd already thought about that particular possiblity, and turned weaponGive into a MAXPLAYER array Smiley

What's the difference between MAXPLAYER and MAXPLAYERCUSTOM?

Logged
Revan
Sr. Member
****
Posts: 346



View Profile
« Reply #8 on: December 02, 2012, 02:53:05 PM »

//for all war3source or SH plugins, we define MAXPlAYERS as 66
//just so pigs dont fly when you run a 64 slot server with HLTV
#define MAXPLAYERSCUSTOM 66   //+2 of real for normal servers, add +X number of HLTV slots
Logged

#war3source
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2169



View Profile WWW
« Reply #9 on: December 03, 2012, 08:25:05 AM »

pigs dont fly
trololol

it happened
Logged

DarkEnergy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!