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

Solved [CSGO] how i can replace weapon for player ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-18-2018 , 06:40   [CSGO] how i can replace weapon for player ?
Reply With Quote #1

hi guys!!
players every round get 1 medic kit and no limited!!
if player not used medic kit, it will be added number of medic kit and no limited!!
i want limited number of medic kit, if player not used medic kit removed it.
please help!!

PHP Code:
#include <sourcemod> 
#include <sdktools_functions> 
#pragma semicolon 1 
#pragma newdecls required 

public void OnPluginStart() 

    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post); 


public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast

    
int iUser GetClientOfUserId(event.GetInt("userid")); 
    if (
IsClientInGame(iUser)) 
    { 
        
CreateTimer(0.7Timer_DelayiUser); // Delay to be safe 
    



public 
Action Timer_Delay(Handle timerany client

    if (
IsClientInGame(client)) 
    { 
        
GivePlayerItem(client"weapon_healthshot"); 
    } 


Last edited by Dr.Mohammad; 12-19-2018 at 15:01.
Dr.Mohammad is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-18-2018 , 07:51   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #2

You have set ammo_item_limit_healthshot ? It's 4 by default.

sm_cvar ammo_item_limit_healthshot 1
__________________
Do not Private Message @me

Last edited by Bacardi; 12-18-2018 at 07:57.
Bacardi is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-18-2018 , 09:26   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
You have set ammo_item_limit_healthshot ? It's 4 by default.

sm_cvar ammo_item_limit_healthshot 1
thank you!!

how i can remove ak47,deagle,healthshot,grenade and other weapon from players??
What is the best way ؟؟
Dr.Mohammad is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-18-2018 , 16:05   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #4

I made example to your first post, because you would get healtshots in spawn every round start.

This check first, does player have healt shot or how many (follow cvar ammo_item_limit_healthshot value)

PHP Code:
#include <sdktools>

ConVar ammo_item_limit_healthshot;

public 
void OnPluginStart()
{
    
ammo_item_limit_healthshot FindConVar("ammo_item_limit_healthshot");
    if(
ammo_item_limit_healthshot == INVALID_HANDLESetFailState("No Cvar ammo_item_limit_healthshot found");

    
HookEvent("player_spawn"player_spawn);
}

public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if(
GetClientTeam(client) <= 1) return; // player need to be in right team


    
char classname[35];
    
int m_hMyWeapons_size GetEntPropArraySize(clientProp_Send"m_hMyWeapons"); // array size
    
int item;
    
bool m_bHasHealthShot;

    for(
int index 0index m_hMyWeapons_sizeindex++) // look player items
    
{
        
item GetEntPropEnt(clientProp_Send"m_hMyWeapons"index);

        if(
item == -1) continue; // skip invalid

        
GetEntityClassname(itemclassnamesizeof(classname));

        
// Health Shot
        
if(StrEqual(classname"weapon_healthshot"false))
        {
            
m_bHasHealthShot true;

            
int ammotype GetEntProp(itemProp_Send"m_iPrimaryAmmoType");

            if(
ammotype == -1) continue; // skip if ammo type offset invalid

            
int ammo GetEntProp(clientProp_Send"m_iAmmo"_ammotype);
            if(
ammo ammo_item_limit_healthshot.IntValue)
            {
                
SetEntProp(clientProp_Send"m_iAmmo"ammo 1_ammotype);
                
//GivePlayerItem(client, "weapon_healthshot");
            
}
        }
    }


    if(!
m_bHasHealthShot && ammo_item_limit_healthshot.IntValue 0GivePlayerItem(client"weapon_healthshot");





There is https://sm.alliedmods.net/new-api/cs...OnCSWeaponDrop

I look another time, I go sleep
__________________
Do not Private Message @me

Last edited by Bacardi; 12-18-2018 at 16:05.
Bacardi is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-18-2018 , 22:26   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #5

thank you!!

this is true?? for remove waepon and give weapon:

PHP Code:

void VipMenu
(int client)
{
    
Menu vipmenu = new Menu(VIPMenu_HandlerMENU_ACTIONS_ALL);
    
    
vipmenu.SetTitle("VIPMenu");
    
    
vipmenu.AddItem("AK47D""AK47 + Deagle");
    
    
vipmenu.AddItem("M4A4D""M4A4 + Deagle");
    
    
vipmenu.ExitButton true;
    
    
vipmenu.Display(clientInt_vip_menu_time);
}

public 
int VIPMenu_Handler(Menu vipmenuMenuAction actionint clientint item)
{
    
char choice_item[32];
    
vipmenu.GetItem(itemchoice_itemsizeof(choice_item));
    if (
action == MenuAction_Select)
    {
        if (
StrEqual(choice_item"AK47D"))
        {
            
RemoveClientPrimaryWeapons(client);
            
RemoveClientSecondaryWeapons(client);
            
GivePlayerItem(client"weapon_deagle");
            
GivePlayerItem(client"weapon_ak47");
            
CPrintToChat(client"[{green} %s{default} ] {default}You choosed {purple}AK47 + DEAGLE! {lightgreen}HAVE FUN!"TAG);
        }
        else if (
StrEqual(choice_item"M4A4D"))
        {
            
RemoveClientPrimaryWeapons(client);
            
RemoveClientSecondaryWeapons(client);
            
GivePlayerItem(client"weapon_m4a1");
            
GivePlayerItem(client"weapon_deagle");
            
CPrintToChat(client"[{green} %s{default} ] {default}You choosed {purple}M4A4 + DEAGLE! {lightgreen}HAVE FUN!"TAG);
        }
        else if (
StrEqual(choice_item"M4A1-SD"))
        {
            
RemoveClientPrimaryWeapons(client);
            
RemoveClientSecondaryWeapons(client);
            
GivePlayerItem(client"weapon_m4a1_silencer");
            
GivePlayerItem(client"weapon_deagle");
            
CPrintToChat(client"[{green} %s{default} ] {default}You choosed {purple}M4A1-S + DEAGLE! {lightgreen}HAVE FUN!"TAG);
        }
        else
        {
            
VipMenu(client);
        }
    }
    else if (
action == MenuAction_End)
    {
        
delete vipmenu;
    }
}

/*********************************
 *  RemoveClientPrimaryWeapons
 *********************************/
 
void RemoveClientPrimaryWeapons(int client)
{
    
int weapon_index = -1

    if((
weapon_index GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY)) != -1
    { 
        if (
IsValidEntity(weapon_index)) 
        { 
            
RemovePlayerItem(clientweapon_index); 
            
AcceptEntityInput(weapon_index"Kill");  
        } 
    }
}

/*********************************
 *  RemoveClientPrimaryWeapons
 *********************************/
void RemoveClientSecondaryWeapons(int client

    
int weapon_index = -1

    if((
weapon_index GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY)) != -1
    { 
        if (
IsValidEntity(weapon_index)) 
        { 
            
RemovePlayerItem(clientweapon_index); 
            
AcceptEntityInput(weapon_index"Kill");  
        } 
    }


Last edited by Dr.Mohammad; 12-18-2018 at 22:49.
Dr.Mohammad is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-19-2018 , 07:30   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #6

Yeah, perhaps that work nicely. I haven't tested.

*edit
Just one thing, if player can join spectator team, he then can spawn weapons also. You maybe need check in which team player is.

Last edited by Bacardi; 12-19-2018 at 09:29.
Bacardi is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-19-2018 , 15:00   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Yeah, perhaps that work nicely. I haven't tested.

*edit
Just one thing, if player can join spectator team, he then can spawn weapons also. You maybe need check in which team player is.
thank you
i checking team before spawn!
Dr.Mohammad is offline
Terminatorr
Member
Join Date: Dec 2018
Old 12-25-2018 , 22:57   Re: [CSGO] how i can replace weapon for player ?
Reply With Quote #8

Quote:
Originally Posted by Dr.Mohammad View Post
thank you
i checking team before spawn!
Hi, i was looking for something similar can you post your full code please? with checking teams ..etc.
Terminatorr is offline
Reply


Thread Tools
Display Modes

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:29.


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