Raised This Month: $32 Target: $400
 8% 

Check if player has a zeus, than give. If he has - don't give a new one.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 08-21-2017 , 10:36   Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #1

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

#define CS_TEAM_T    2
#define CS_TEAM_CT    3 

#define     HEGrenadeOffset         14    
#define     FlashbangOffset         15 
#define     SmokegrenadeOffset        16

public OnPluginStart()
{
   
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iClient GetClientOfUserId(GetEventInt(event"userid"));
    new 
clientTeam GetClientTeam(iClient);
    
    if(
VIP_IsClientVIP(iClient) && IsValidPlayer(iClient))
    {
        
SetEntProp(iClientProp_Send"m_ArmorValue"100);
        
SetEntProp(iClientProp_Send"m_bHasHelmet"1);

        if(
IsClientInGame(iClient) && IsPlayerAlive(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_SmokegrenadeOffset)==0){    
        
GivePlayerItem(iClient"weapon_smokegrenade");}
        
        if(
IsClientInGame(iClient) && IsPlayerAlive(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_HEGrenadeOffset)==0){    
        
GivePlayerItem(iClient"weapon_hegrenade");}
        
        if(
IsClientInGame(iClient) && IsPlayerAlive(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_FlashbangOffset)==0){    
        
GivePlayerItem(iClient"weapon_flashbang");}
        
        
GivePlayerItem(iClient"weapon_taser");
        
        if(
clientTeam == CS_TEAM_CT)
        {
            
SetEntProp(iClientProp_Send"m_bHasDefuser"1);    
        }
    }


/***************************************************************************/
bool:IsValidPlayer(iClient) {
    if (
iClient || iClient MaxClients || !IsClientConnected(iClient))
        return 
false;
    return 
IsClientInGame(iClient);
}  
/**************************************************************************/ 
__________________

Last edited by PinHeaDi; 08-21-2017 at 13:20.
PinHeaDi is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 08-21-2017 , 18:57   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #2

I rewrote it with Kailo's snippet( https://forums.alliedmods.net/showthread.php?t=300574 )
Also I rewrited it with new syntax and changed a little of code
I recommend you compile plugin by own from scripting, because our vip_core include can be others
Attached Files
File Type: zip GiveWeapons.zip (7.6 KB, 66 views)
__________________


Max-Play.pl - the best polish servers

Last edited by CamerDisco; 08-21-2017 at 19:00.
CamerDisco is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 08-21-2017 , 19:18   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #3

I get

PHP Code:
L 08/22/2017 02:15:28: [SMException reportedElement -1 is out of bounds (Prop m_iAmmo has 32 elements).
L 08/22/2017 02:15:28: [SMBlamingvip/vip_test.smx
L 08
/22/2017 02:15:28: [SMCall stack trace:
L 08/22/2017 02:15:28: [SM]   [0GetEntProp
L 08
/22/2017 02:15:28: [SM]   [1Line 73C:\Users\SSadistic\Desktop\SMCompile\vip_test.sp::Event_PlayerSpawn 
I guess it has something to do with the zeus, since it doenst give it.
__________________
PinHeaDi is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 08-21-2017 , 20:00   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #4

I didn't test this method, so I did it by other way.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <vip_core>
#include <cstrike>

int flashsmokehetaser;

public 
void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

//getting ammo offsets by Adi(http://sklepcs.pl/)
public void OnMapStart()
{
    
int entindex CreateEntityByName("weapon_hegrenade");
    
DispatchSpawn(entindex);
    
he GetEntProp(entindexProp_Send"m_iPrimaryAmmoType");
    
AcceptEntityInput(entindex"Kill");
    
    
entindex CreateEntityByName("weapon_smokegrenade");
    
DispatchSpawn(entindex);
    
smoke GetEntProp(entindexProp_Send"m_iPrimaryAmmoType");
    
AcceptEntityInput(entindex"Kill");
    
    
entindex CreateEntityByName("weapon_flashbang");
    
DispatchSpawn(entindex);
    
flash GetEntProp(entindexProp_Send"m_iPrimaryAmmoType");
    
AcceptEntityInput(entindex"Kill");
    
    
entindex CreateEntityByName("weapon_taser");
    
DispatchSpawn(entindex);
    
taser GetEntProp(entindexProp_Send"m_iPrimaryAmmoType");
    
AcceptEntityInput(entindex"Kill");
}

public 
Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int iClient GetClientOfUserId(event.GetInt("userid"));
    
int clientTeam GetClientTeam(iClient);
    
    if(
VIP_IsClientVIP(iClient) && IsValidPlayer(iClient))
    {
        
SetEntProp(iClientProp_Send"m_ArmorValue"100);
        
SetEntProp(iClientProp_Send"m_bHasHelmet"1);

        if(
IsClientInGame(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_smoke) == 0
            
GivePlayerItem(iClient"weapon_smokegrenade");
        
        if(
IsClientInGame(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_he) == 0)  
            
GivePlayerItem(iClient"weapon_hegrenade");
        
        if(
IsClientInGame(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_flash) == 0)    
            
GivePlayerItem(iClient"weapon_flashbang");
        
        if(
IsClientInGame(iClient) && GetEntProp(iClientProp_Data"m_iAmmo"_taser) == 0
            
GivePlayerItem(iClient"weapon_taser");
        
        if(
clientTeam == CS_TEAM_CT)
        {
            
SetEntProp(iClientProp_Send"m_bHasDefuser"1);    
        }
    }


stock bool IsValidPlayer(int iClient) {
    if (
iClient || iClient MaxClients || !IsClientConnected(iClient))
        return 
false;
    return 
IsClientInGame(iClient);

__________________


Max-Play.pl - the best polish servers
CamerDisco is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 08-22-2017 , 07:16   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #5

PHP Code:
L 08/22/2017 14:15:11SourceMod error session started
L 08
/22/2017 14:15:11Info (map "de_dust2") (file "errors_20170822.log")
L 08/22/2017 14:15:11: [SMException reportedElement -1 is out of bounds (Prop m_iAmmo has 32 elements).
L 08/22/2017 14:15:11: [SMBlamingvip/vip_test.smx
L 08
/22/2017 14:15:11: [SMCall stack trace:
L 08/22/2017 14:15:11: [SM]   [0GetEntProp
L 08
/22/2017 14:15:11: [SM]   [1Line 73C:\Users\SSadistic\Desktop\SMCompile\vip_test.sp::Event_PlayerSpawn 
__________________
PinHeaDi is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 08-22-2017 , 08:13   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #6

1) Zuse ammo type is "AMMO_TYPE_TASERCHARGE", not "AMMO_TYPE_TASER"
2)
Code:
if(VIP_IsClientVIP(iClient) && IsValidPlayer(iClient))
replace to
Code:
if(IsValidPlayer(iClient) && VIP_IsClientVIP(iClient))
I used vip_core.inc of [VIP] Core. Is right?
Attached Files
File Type: zip GiveWeapons.zip (11.4 KB, 72 views)

Last edited by Kailo; 08-22-2017 at 08:14.
Kailo is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 08-22-2017 , 09:00   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #7

Quote:
Originally Posted by Kailo View Post
1) Zuse ammo type is "AMMO_TYPE_TASERCHARGE", not "AMMO_TYPE_TASER"
2)
Code:
if(VIP_IsClientVIP(iClient) && IsValidPlayer(iClient))
replace to
Code:
if(IsValidPlayer(iClient) && VIP_IsClientVIP(iClient))
I used vip_core.inc of [VIP] Core. Is right?
Now it works. So I decided to add extra money for kill in the plugin:

PHP Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
Extramoney(GetClientOfUserId(GetEventInt(event"attacker")), GetEventBool(event"headshot") ? headshot kill);
}

Extramoney(iClientaward)
{
    if(
iClient && VIP_IsClientVIP(iClient) && IsValidPlayer(iClient))
    {
        new 
money GetEntProp(iClientProp_Send"m_iAccount");
        switch(
award)
        {
            case 
kill:        money += BONUS_MONEY_NORMAL_KILL;
            case 
headshot:    money += BONUS_MONEY_HEADSHOT_KILL;
        }
        
SetEntProp(iClientProp_Send"m_iAccount"money);
    }

PHP Code:
#define BONUS_MONEY_NORMAL_KILL        200
#define BONUS_MONEY_HEADSHOT_KILL    300 
I got that from an old plugin here, but it doesn't give the money properly.
__________________
PinHeaDi is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 08-22-2017 , 11:00   Re: Check if player has a zeus, than give. If he has - don't give a new one.
Reply With Quote #8

PHP Code:
//global int
int g_iAccount;

public 
void OnPluginStart()
{
    
g_iAccount FindSendPropInfo("CCSPlayer""m_iAccount");
}

void Extramoney(int iClientint award)
{
    if(
IsValidPlayer(iClient) && VIP_IsClientVIP(iClient))
    {
        
int money GetEntData(iClientg_iAccount);
        switch(
award)
        {
            case 
kill:        money += BONUS_MONEY_NORMAL_KILL;
            case 
headshot:    money += BONUS_MONEY_HEADSHOT_KILL;
        }
        
SetEntData(iClientg_iAccountmoney);
    }

__________________


Max-Play.pl - the best polish servers
CamerDisco 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 12:05.


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