Raised This Month: $12 Target: $400
 3% 

[CS:GO] Give glock with no ammo on player spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
peewee41
Member
Join Date: Jul 2009
Old 10-11-2012 , 20:13   [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #1

Hi all,

Just wondering if someone can write a simple plugin for CS:GO which will give each player a glock with no ammo when they spawn?

Cheers,
pw
peewee41 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-16-2012 , 06:13   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #2

PHP Code:
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
    
HookEvent"player_spawn",            EVENT_PlayerSpawn );
}

public 
EVENT_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserIdGetEventIntevent"userid" ));
    if ( 
IsValidClientclient ))
    {
        
CreateTimer0.1Timer_Glockclient );
    }
}

public 
Action:Timer_Glock(Handle:timerany:client)
{
    if ( 
IsValidClientclient ))
    {
        new 
GetPlayerWeaponSlotclient);
        if ( 
!= -)
        {
            
SetEntDataEnt2wFindSendPropOffs("CBaseCombatWeapon""m_hOwnerEntity"), -);
            
AcceptEntityInputw"kill" );
            
GiveWeaponclient"weapon_glock" ); // <----- should be no ammo or just set the player m_iAmmo data to zero. That way is easyer.
        
}
    }
}

stock GiveWeaponclient, const String:wName[] )
{
    if ( 
IsValidClientclient ))
    {
        new 
wep;
        
decl Float:noB[3];
        
GetEntPropVectorclientProp_Send"m_vecOrigin"noB );
    
        
wep CreateEntityByNamewName );
        if ( 
wep != -)
        {
            
SetEntDataEnt2wepFindSendPropOffs("CBaseCombatWeapon""m_hOwnerEntity"), client );
            
DispatchSpawnwep );
            
TeleportEntitywepnoBNULL_VECTORNULL_VECTOR );
            
EquipPlayerWeaponclientwep );
            
SetEntPropEntclientProp_Send"m_hActiveWeapon"wep );
        }
    }
}

stock bool:IsValidClientclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    if ( !
IsPlayerAliveclient )) return false;
    return 
true;

Untested..

Last edited by GsiX; 10-16-2012 at 07:23.
GsiX is offline
peewee41
Member
Join Date: Jul 2009
Old 10-16-2012 , 18:43   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #3

Hey thanks for helping. It gives the players the glock, but it's still loaded with bullets (20/120).
peewee41 is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-16-2012 , 19:54   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #4

You will need to edit player NetProp, forgot which one exactly.
__________________
FaTony is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-16-2012 , 23:38   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #5

Yay.. i dont have any accses of CS:GO netprop..

The code i give to you is from my CS:S plugin and yes.. it no ammo the first time they received it. What i did is set the m_iAmmo on the player.

In your case is revers the process.. Question, why do u want to give everybody a glock anyway? I have no idea since i never play this game till now.

EDIT: or you cant beat the bot if they using other than glock?

Last edited by GsiX; 10-16-2012 at 23:43.
GsiX is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-18-2012 , 13:37   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #6

Seems in cs:go, it will refill player m_iAmmo inside buyzone when there buy time left.
Set game cvar ammo_9mm_max "0" is one way remove ammo. But affect also to weapons what use 9mm ammo type.
Bacardi is offline
peewee41
Member
Join Date: Jul 2009
Old 10-18-2012 , 17:32   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #7

Quote:
Originally Posted by GsiX View Post
Question, why do u want to give everybody a glock anyway? I have no idea since i never play this game till now.

EDIT: or you cant beat the bot if they using other than glock?
ahaha nah it's for a soccer server where since we can't view enemy names with knives, we're gonna give them an unloaded glock so they can use that to see the enemy names.

Thanks for that suggestion Bacardi!
peewee41 is offline
peewee41
Member
Join Date: Jul 2009
Old 10-18-2012 , 19:01   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #8

Ok I've tested the cvar and the script on the soccer map - two issues I noticed:
  • Ammo is 20/0, not 0/0
  • Glock isn't given on the soccer maps
    • I assume this is because the players don't spawn with a pistol on the soccer maps like they do on the normal maps
peewee41 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 10-18-2012 , 21:14   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #9

You use like this

PHP Code:
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
    
HookEvent"player_spawn",            EVENT_PlayerSpawn );
}

public 
EVENT_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserIdGetEventIntevent"userid" ));
    if ( 
IsValidClientclient ))
    {
        
CreateTimer0.1Timer_Glockclient );
    }
}

public 
Action:Timer_Glock(Handle:timerany:client)
{
    if ( 
IsValidClientclient ))
    {
        new 
GetPlayerWeaponSlotclient);
        if ( 
!= -)
        {
            
SetEntDataEnt2wFindSendPropOffs("CBaseCombatWeapon""m_hOwnerEntity"), -);
            
AcceptEntityInputw"kill" );
        }
        
GiveWeaponclient"weapon_glock" );
        
        
SetEntDataclient, (( FindDataMapOffsclient"m_iAmmo" )) + 24 ), 0); // <---- if you still getting ammo then you shoul seek help for the ammo offset here. The number 24.
    
}
}

stock GiveWeaponclient, const String:wName[] )
{
    if ( 
IsValidClientclient ))
    {
        new 
wep;
        
decl Float:noB[3];
        
GetEntPropVectorclientProp_Send"m_vecOrigin"noB );
    
        
wep CreateEntityByNamewName );
        if ( 
wep != -)
        {
            
SetEntDataEnt2wepFindSendPropOffs("CBaseCombatWeapon""m_hOwnerEntity"), client );
            
DispatchSpawnwep );
            
            
SetEntPropwepProp_Send"m_iClip1"01);
            
            
TeleportEntitywepnoBNULL_VECTORNULL_VECTOR );
            
EquipPlayerWeaponclientwep );
            
SetEntPropEntclientProp_Send"m_hActiveWeapon"wep );
        }
    }
}

stock bool:IsValidClientclient )
{
    if ( 
client || client MaxClients ) return false;
    if ( !
IsClientConnectedclient )) return false;
    if ( !
IsClientInGameclient )) return false;
    if ( !
IsPlayerAliveclient )) return false;
    return 
true;


Last edited by GsiX; 10-18-2012 at 21:38.
GsiX is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 10-18-2012 , 21:29   Re: [CS:GO] Give glock with no ammo on player spawn
Reply With Quote #10

Wow, why timer, why complex and convoluted GiveWeapon, isn's GivePlayerItem enough?

PHP Code:
#include <smlib/weapons>

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
weapon GivePlayerItem(client"weapon_glock");
    
Weapon_SetPrimaryClip(weapon0);

__________________
FaTony 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 20:02.


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