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

Help trying to use item_kevlar in my sp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
trucka
Junior Member
Join Date: Jan 2019
Old 01-10-2019 , 17:39   Help trying to use item_kevlar in my sp
Reply With Quote #1

Trying to create a plugin that gives only kevlar to Ct's NOT helmet and armor. I realize you can use mp_free_armor 1 however I want it only for one team so this wouldn't work. Plugin seems to compile fine but its not working. Any help is much appreciated.

Code:
#include <sourcemod>
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>



public Plugin:myinfo =
{
    name = "armor for ct",
    description = "basic plugin, give 100 armor to all cts uses code from last ct. Repurposed of course",
    author = "trucka",
    version = "1.0",
    url = ""
};


public OnPluginStart()
{
    HookEvent("round_start", roundStart);
}

public roundStart(Handle:event, String:name[], bool:dontBroadcast)
{
    new userid = GetEventInt(event, "userid");
    new client = GetClientOfUserId(userid);
    if (IsClientInGame(client) && GetClientTeam(client) == 3 && IsPlayerAlive(client)) {
		GivePlayerItem(client, "item_kevlar");
	}
}

Last edited by trucka; 01-10-2019 at 18:08.
trucka is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 01-10-2019 , 18:59   Re: Help trying to use item_kevlar in my sp
Reply With Quote #2

round_start does not have a userid parameter. So it will always be 0. You have to loop through all players and then check the teams and give the kevlar.

Last edited by xerox8521; 01-10-2019 at 19:00.
xerox8521 is offline
sdz
Senior Member
Join Date: Feb 2012
Old 01-10-2019 , 20:26   Re: Help trying to use item_kevlar in my sp
Reply With Quote #3

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

public Plugin myinfo =
{
    
name "armor for ct",
    
description "basic plugin, give 100 armor to all cts uses code from last ct. Repurposed of course",
    
author "trucka",
    
version "1.0",
    
url ""
};


public 
void OnPluginStart()
{
    
HookEvent("round_start"roundStart);
}

public 
void roundStart(Event eventchar[] namebool dontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientConnected(i) || !IsClientInGame(i)) continue;
        if(
GetClientTeam(i) == CS_TEAM_CT && IsPlayerAlive(i)) GivePlayerItem(i"item_kevlar");
    }

sdz 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 04:01.


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