Raised This Month: $ Target: $400
 0% 

[CSGO] GivePlayerItem gives 2 grenades


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 02-01-2016 , 12:47   [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #1

Hello. I've written a small plugin that should give grenades after PlayerSpawn and it does give, but it gives two of them, and I want it to spawn only one.
CVars are correct (ammo_grenade_limit_default and _flashbang set to 1) but it does spawn additional smoke and flashbang on the ground, under player's foot. I don't know why, that's why I need help

code:
PHP Code:
public Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
    if (
client && IsPlayerAlive(client))
    {
        if (
IsPlayerGenericAdmin(client))
        {
            
CreateTimer(1.0GiveStuffToPlayerclient);
        }
    }
}

public 
Action GiveStuffToPlayer(Handle timerany client)
{            
    
GivePlayerItem(client"weapon_smokegrenade");
    
GivePlayerItem(client"weapon_flashbang");
    
SetEntProp(clientProp_Send"m_ArmorValue"100); 
    
SetEntProp(clientProp_Send"m_bHasHelmet"1); 

__________________
This is my signature.
bcKq is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 02-01-2016 , 14:14   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #2

Are you sure it's not just getting called twice?
Miu is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 02-01-2016 , 17:36   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #3

This event is called once when you're put in game, no?
__________________

Last edited by micapat; 02-01-2016 at 17:37.
micapat is offline
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 02-01-2016 , 17:40   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #4

The only time this function (GiveStuffToPlayer) is called is by CreateTimer (which should be called just once, right?). And it doesn't happen just after joining the game, it happens every round.
__________________
This is my signature.
bcKq is offline
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 02-01-2016 , 19:21   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #5

I'm guessing maybe you have another plugin that is affecting this.

Just try adding:
PrintToChatAll("test");

Inside: GiveStuffToPlayer

And see if it prints 'test' twice when you spawn.
__________________
STEAM: /id/invexbyte | Github: Mo Beigi | Discord: Byte#0017
Community: Invex Gaming | My Plugins: Click Me!

Byte is offline
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 02-05-2016 , 17:01   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #6

I found the problem, OnPlayerSpawn is called twice... but why?
First spawn is OK after mapchange, but when I spawn again it's calling it 2 times.
__________________
This is my signature.

Last edited by bcKq; 02-05-2016 at 17:05.
bcKq is offline
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 02-06-2016 , 09:21   Re: [CSGO] GivePlayerItem gives 2 grenades
Reply With Quote #7

Ok, so the problem is (I think) using Arena mod. player_spawn from what I read is called when player spawns and when he changes team, and since Arena transfers player to another team it's called twice.
__________________
This is my signature.
bcKq is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode