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

Solved [CS:GO] Detect if a player spawned in a buyzone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 03-16-2019 , 12:45   [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #1

So I've been trying to detect if a player is inside a BuyZone when he spawns but it's always returning 0 is there anything that I'm doing wrong?

Basically I'm getting the m_bInBuyZone in the event OnPlayerSpawn.

PHP Code:
GetEntProp(iClientProp_Send"m_bInBuyZone"); 
I've tested it with PrintToServer and it returns 0 when it is inside the event OnPlayerSpawn.
Even if I put it in a timer always checking the players it returns the correct values but the things that are OnPlayerSpawn won't work.

Not sure if I've been clear enough, if not ask and I'll try to explain the best I can.

Last edited by manicogaming; 03-19-2019 at 06:01.
manicogaming is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 14:24   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #2

Can you show your OnPluginStart and OnPlayerSpawn functions?
Mathias. is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 03-16-2019 , 14:33   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #3

Here OnPluginStart

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"PlayerSpawn);
    
g_hFakeRank RegClientCookie("LR_FakeRank""LR_FakeRank"CookieAccess_Private);
    
LoadTranslations("levels_ranks_fakerank.phrases");

    for(
int iClient 1iClient <= MaxClientsiClient++)
    {
        if(
IsClientInGame(iClient) && IsFakeClient(iClient))
        {
            if(
AreClientCookiesCached(iClient))
            {
                
OnClientCookiesCached(iClient);
            }
            
OnClientPostAdminCheck(iClient);
        }
    }

Here is OnPlayerSpawn:

PHP Code:
public void PlayerSpawn(Handle hEventchar[] sEvNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    
g_iRankPlayers[iClient] = LR_GetClientInfo(iClientST_RANK);
    
    
int rnd GetRandomInt(1,15);
    switch(
rnd)
    {
        case 
1:
        {
            
g_iCoin[iClient] = GetRandomInt(874,970);
        }
        case 
2:
        {
            
g_iCoin[iClient] = GetRandomInt(1001,1010);
        }
        case 
3:
        {
            
g_iCoin[iClient] = GetRandomInt(1013,1022);
        }
        case 
4:
        {
            
g_iCoin[iClient] = GetRandomInt(1024,1026);
        }
        case 
5:
        {
            
g_iCoin[iClient] = GetRandomInt(1028,1055);
        }
        case 
6:
        {
            
g_iCoin[iClient] = GetRandomInt(1316,1318);
        }
        case 
7:
        {
            
g_iCoin[iClient] = GetRandomInt(1327,1329);
        }
        case 
8:
        {
            
g_iCoin[iClient] = GetRandomInt(1331,1332);
        }
        case 
9:
        {
            
g_iCoin[iClient] = GetRandomInt(1336,1344);
        }
        case 
10:
        {
            
g_iCoin[iClient] = GetRandomInt(1357,1363);
        }
        case 
11:
        {
            
g_iCoin[iClient] = GetRandomInt(1367,1372);
        }
        case 
12:
        {
            
g_iCoin[iClient] = GetRandomInt(1376,1381);
        }
        case 
13:
        {
            
g_iCoin[iClient] = GetRandomInt(4353,4356);
        }
        case 
14:
        {
            
g_iCoin[iClient] = GetRandomInt(6001,6033);
        }
        case 
15:
        {
            
g_iCoin[iClient] = GetRandomInt(4555,4558);
        }
    }
    
    if(
IsFakeClient(iClient))
    {
        
int m_iAccount GetEntProp(iClientProp_Send"m_iAccount");
        
int team GetClientTeam(iClient);
        
        
int m_bHasDefuser GetEntProp(iClientProp_Send"m_bHasDefuser");
        
m_bInBuyZone GetEntProp(iClientProp_Send"m_bInBuyZone");
        
        if(
m_bInBuyZone == 0)
        {
            if((
m_iAccount 1500) && (m_iAccount 3000))
            {
                
int iWeapon GetPlayerWeaponSlot(iClientCS_SLOT_SECONDARY);
                
                if (
iWeapon != -1)
                {
                    
RemovePlayerItem(iClientiWeapon);
                }
                
                
int rndpistol GetRandomInt(1,3);
                
                switch(
rndpistol)
                {
                    case 
1:
                    {
                        
GivePlayerItem(iClient"weapon_p250");
                        
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 300);
                    }
                    case 
2:
                    {
                        if(
team == 3)
                        {
                            
int ctcz GetRandomInt(1,2);
                            
                            switch(
ctcz)
                            {
                                case 
1:
                                {
                                    
GivePlayerItem(iClient"weapon_fiveseven");
                                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                                }
                                case 
2:
                                {
                                    
GivePlayerItem(iClient"weapon_cz75a");
                                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                                }
                            }
                        }
                        else if(
team == 2)
                        {
                            
int tcz GetRandomInt(1,2);
                            
                            switch(
tcz)
                            {
                                case 
1:
                                {
                                    
GivePlayerItem(iClient"weapon_tec9");
                                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                                }
                                case 
2:
                                {
                                    
GivePlayerItem(iClient"weapon_cz75a");
                                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                                }
                            }
                        }
                    }
                    case 
3:
                    {
                        
GivePlayerItem(iClient"weapon_deagle");
                        
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 700);
                    }
                }
            }
            else if(
m_iAccount 3000)
            {
                
RemoveNades(iClient);
                
                
int rndnades GetRandomInt(1,4);
                
                switch(
rndnades)
                {
                    case 
1:
                    {
                        
GivePlayerItem(iClient"weapon_flashbang");
                    }
                    case 
2:
                    {
                        
GivePlayerItem(iClient"weapon_smokegrenade");
                    }
                    case 
3:
                    {
                        
GivePlayerItem(iClient"weapon_hegrenade");
                    }
                    case 
4:
                    {
                        if(
team == 3)
                        {
                            
GivePlayerItem(iClient"weapon_incgrenade");
                        }
                        if(
team == 2)
                        {
                            
GivePlayerItem(iClient"weapon_molotov");
                        }
                    }
                }
                if(
team == 3)
                {
                    if(
m_bHasDefuser != 0)
                    {
                        
GivePlayerItem(iClient"item_defuser");
                    }
                }
            }
        }
        
        if(
GetRandomInt(1,10) == 1)
        {
            if(
team == 3)
            {
                
char usp[32];
                
                
GetClientWeapon(iClientuspsizeof(usp));
                
                if(
StrEqual(usp"weapon_usp_silencer"))
                {
                    
int uspslot GetPlayerWeaponSlot(iClientCS_SLOT_SECONDARY);
                    
                    if (
uspslot != -1)
                    {
                        
RemovePlayerItem(iClientuspslot);
                    }
                    
GivePlayerItem(iClient"weapon_hkp2000");
                }
            }
        }
    }
    
CheckRankType(iClient);

EDIT: This is the Level Ranks Fake Rank plugin but I'm editing it to improve bots.

Last edited by manicogaming; 03-16-2019 at 14:41.
manicogaming is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 14:43   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #4

Ok I have found out why it doesn't work, even tho the Event is hook with EventHookMode_Post you have to wait a frame to check the value.

I have also added the enter_buyzone and exit_buyzone event they might be useful for you. The reason why I made extra check after a frame is that it might be possible the client disconnect or die in that frame (I actually have no clue tbh lol)
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#pragma newdecls required

public Plugin myinfo 
{
    
name "m_bInBuyZone",
    
author "A guy in Canada",
    
description "",
    
version "13.3.7",
    
url "https://forums.alliedmods.net/showthread.php?t=314996"
};

public 
void OnPluginStart() {
    
HookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);
    
HookEvent("enter_buyzone"OnEnteringBuyZoneEventHookMode_Post);
    
HookEvent("exit_buyzone"OnExitingBuyZoneEventHookMode_Post);
}

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

    if (!
client) return;

    
RequestFrame(RFrame_CheckBuyZoneValueclient);
}

public 
void RFrame_CheckBuyZoneValue(int client) {
    if (!
IsClientInGame(client) || !IsPlayerAlive(client)) return;

    
bool inBuyZone view_as<bool>(GetEntProp(clientProp_Send"m_bInBuyZone"));
    
PrintToChat(client"-> m_bInBuyZone value %d"inBuyZone);
}

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

    if (!
client) return;

    
PrintToChat(client"-> You have entered the buyzone.");
}

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

    if (!
client) return;

    
PrintToChat(client"-> You have exited the buyzone.");


Last edited by Mathias.; 03-16-2019 at 14:50.
Mathias. is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 03-16-2019 , 15:22   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #5

And where should I put this:

PHP Code:
if(IsFakeClient(client))
{
    
int m_iAccount GetEntProp(clientProp_Send"m_iAccount");
    
int team GetClientTeam(client);
    
    if(
inBuyZone)
    {
        if((
m_iAccount 1500) && (m_iAccount 3000))
        {
            
int iWeapon GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);
            
            if (
iWeapon != -1)
            {
                
RemovePlayerItem(clientiWeapon);
            }
            
            
int rndpistol GetRandomInt(1,3);
            
            switch(
rndpistol)
            {
                case 
1:
                {
                    
GivePlayerItem(client"weapon_p250");
                    
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 300);
                }
                case 
2:
                {
                    if(
team == 3)
                    {
                        
int ctcz GetRandomInt(1,2);
                        
                        switch(
ctcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(client"weapon_fiveseven");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(client"weapon_cz75a");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                    else if(
team == 2)
                    {
                        
int tcz GetRandomInt(1,2);
                        
                        switch(
tcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(client"weapon_tec9");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(client"weapon_cz75a");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                }
                case 
3:
                {
                    
GivePlayerItem(client"weapon_deagle");
                    
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 700);
                }
            }
        }
        else if(
m_iAccount 3000)
        {
            
RemoveNades(client);
            
            
int rndnades GetRandomInt(1,4);
            
            switch(
rndnades)
            {
                case 
1:
                {
                    
GivePlayerItem(client"weapon_flashbang");
                }
                case 
2:
                {
                    
GivePlayerItem(client"weapon_smokegrenade");
                }
                case 
3:
                {
                    
GivePlayerItem(client"weapon_hegrenade");
                }
                case 
4:
                {
                    if(
team == 3)
                    {
                        
GivePlayerItem(client"weapon_incgrenade");
                    }
                    if(
team == 2)
                    {
                        
GivePlayerItem(client"weapon_molotov");
                    }
                }
            }
            if(
team == 3)
            {
                
SetEntProp(clientProp_Send"m_bHasDefuser"1);
            }
        }
    }
    
    if(
GetRandomInt(1,10) == 1)
    {
        if(
team == 3)
        {
            
char usp[32];
            
            
GetClientWeapon(clientuspsizeof(usp));
            
            if(
StrEqual(usp"weapon_usp_silencer"))
            {
                
int uspslot GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);
                
                if (
uspslot != -1)
                {
                    
RemovePlayerItem(clientuspslot);
                }
                
GivePlayerItem(client"weapon_hkp2000");
            }
        }
    }

EDIT: Also I don't think it is working properly

PHP Code:
m_bInBuyZone value 0 

Last edited by manicogaming; 03-16-2019 at 15:27.
manicogaming is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 15:29   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #6

really my dude? -.-

PHP Code:
public void PlayerSpawn(Handle hEventchar[] sEvNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(GetEventInt(hEvent"userid"));
    
g_iRankPlayers[iClient] = LR_GetClientInfo(iClientST_RANK);
    
    
int rnd GetRandomInt(1,15);
    switch(
rnd)
    {
        case 
1:
        {
            
g_iCoin[iClient] = GetRandomInt(874,970);
        }
        case 
2:
        {
            
g_iCoin[iClient] = GetRandomInt(1001,1010);
        }
        case 
3:
        {
            
g_iCoin[iClient] = GetRandomInt(1013,1022);
        }
        case 
4:
        {
            
g_iCoin[iClient] = GetRandomInt(1024,1026);
        }
        case 
5:
        {
            
g_iCoin[iClient] = GetRandomInt(1028,1055);
        }
        case 
6:
        {
            
g_iCoin[iClient] = GetRandomInt(1316,1318);
        }
        case 
7:
        {
            
g_iCoin[iClient] = GetRandomInt(1327,1329);
        }
        case 
8:
        {
            
g_iCoin[iClient] = GetRandomInt(1331,1332);
        }
        case 
9:
        {
            
g_iCoin[iClient] = GetRandomInt(1336,1344);
        }
        case 
10:
        {
            
g_iCoin[iClient] = GetRandomInt(1357,1363);
        }
        case 
11:
        {
            
g_iCoin[iClient] = GetRandomInt(1367,1372);
        }
        case 
12:
        {
            
g_iCoin[iClient] = GetRandomInt(1376,1381);
        }
        case 
13:
        {
            
g_iCoin[iClient] = GetRandomInt(4353,4356);
        }
        case 
14:
        {
            
g_iCoin[iClient] = GetRandomInt(6001,6033);
        }
        case 
15:
        {
            
g_iCoin[iClient] = GetRandomInt(4555,4558);
        }
    }
    
    if(
IsFakeClient(iClient))
    {
        
RequestFrame(RFrame_CheckBuyZoneValueiClient);
        
        if(
GetRandomInt(1,10) == 1)
        {
            if(
team == 3)
            {
                
char usp[32];
                
                
GetClientWeapon(iClientuspsizeof(usp));
                
                if(
StrEqual(usp"weapon_usp_silencer"))
                {
                    
int uspslot GetPlayerWeaponSlot(iClientCS_SLOT_SECONDARY);
                    
                    if (
uspslot != -1)
                    {
                        
RemovePlayerItem(iClientuspslot);
                    }
                    
GivePlayerItem(iClient"weapon_hkp2000");
                }
            }
        }
    }
    
CheckRankType(iClient);


public 
void RFrame_CheckBuyZoneValue(int iClient) {
    if (!
IsClientInGame(iClient) || !IsPlayerAlive(iClient)) return;

    
int m_iAccount GetEntProp(iClientProp_Send"m_iAccount");
    
int team GetClientTeam(iClient);
    
    
int m_bHasDefuser GetEntProp(iClientProp_Send"m_bHasDefuser");
    
int m_bInBuyZone GetEntProp(iClientProp_Send"m_bInBuyZone");
    
    if(
m_bInBuyZone == 0)
    {
        if((
m_iAccount 1500) && (m_iAccount 3000))
        {
            
int iWeapon GetPlayerWeaponSlot(iClientCS_SLOT_SECONDARY);
            
            if (
iWeapon != -1)
            {
                
RemovePlayerItem(iClientiWeapon);
            }
            
            
int rndpistol GetRandomInt(1,3);
            
            switch(
rndpistol)
            {
                case 
1:
                {
                    
GivePlayerItem(iClient"weapon_p250");
                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 300);
                }
                case 
2:
                {
                    if(
team == 3)
                    {
                        
int ctcz GetRandomInt(1,2);
                        
                        switch(
ctcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(iClient"weapon_fiveseven");
                                
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(iClient"weapon_cz75a");
                                
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                    else if(
team == 2)
                    {
                        
int tcz GetRandomInt(1,2);
                        
                        switch(
tcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(iClient"weapon_tec9");
                                
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(iClient"weapon_cz75a");
                                
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                }
                case 
3:
                {
                    
GivePlayerItem(iClient"weapon_deagle");
                    
SetEntProp(iClientProp_Send"m_iAccount"m_iAccount 700);
                }
            }
        }
        else if(
m_iAccount 3000)
        {
            
RemoveNades(iClient);
            
            
int rndnades GetRandomInt(1,4);
            
            switch(
rndnades)
            {
                case 
1:
                {
                    
GivePlayerItem(iClient"weapon_flashbang");
                }
                case 
2:
                {
                    
GivePlayerItem(iClient"weapon_smokegrenade");
                }
                case 
3:
                {
                    
GivePlayerItem(iClient"weapon_hegrenade");
                }
                case 
4:
                {
                    if(
team == 3)
                    {
                        
GivePlayerItem(iClient"weapon_incgrenade");
                    }
                    if(
team == 2)
                    {
                        
GivePlayerItem(iClient"weapon_molotov");
                    }
                }
            }
            if(
team == 3)
            {
                if(
m_bHasDefuser != 0)
                {
                    
GivePlayerItem(iClient"item_defuser");
                }
            }
        }
    }


Last edited by Mathias.; 03-16-2019 at 15:34.
Mathias. is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 15:31   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #7

Quote:
Originally Posted by manicogmaing View Post
And where should I put this:

EDIT: Also I don't think it is working properly

PHP Code:
m_bInBuyZone value 0 
It does work properly after the next frame, just run my first example above if you don't believe me.

Last edited by Mathias.; 03-16-2019 at 15:32.
Mathias. is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 03-16-2019 , 15:48   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #8

Quote:
Originally Posted by Mathias. View Post
It does work properly after the next frame, just run my first example above if you don't believe me.
Yes it does work with your example.

But when they are out a BuyZone it also works.

Am I really dumb by not finding the obvious here?
Attached Files
File Type: sp Get Plugin or Get Source (bot_eco.sp - 239 views - 6.5 KB)
manicogaming is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 15:57   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #9

Quote:
Originally Posted by manicogmaing View Post
Yes it does work with your example.

But when they are out a BuyZone it also works.

Am I really dumb by not finding the obvious here?
I guess you really don't want people to help you out? Your in the scripting section, I gave you 2 solutions to work with, I am not going to do your work, you asked for help, I provided my results, now finish it.

EDIT: sorry I misread, I though you called me dumb. I will check it out after my match.

Last edited by Mathias.; 03-16-2019 at 16:40. Reason: Apologizing to manicogmaing for misreading his last post
Mathias. is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 03-16-2019 , 16:39   Re: [CS:GO] Detect if a player spawned in a buyzone
Reply With Quote #10

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <clientprefs>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>
#pragma newdecls required

public Plugin myinfo 
{
    
name "m_bInBuyZone",
    
author "A guy in Canada",
    
description "",
    
version "13.3.7",
    
url "https://forums.alliedmods.net/showthread.php?t=314996"
};
int g_iaGrenadeOffsets[] = {151716141817};

public 
void OnPluginStart() {
    
HookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);
    
HookEvent("enter_buyzone"OnEnteringBuyZoneEventHookMode_Post);
    
HookEvent("exit_buyzone"OnExitingBuyZoneEventHookMode_Post);
}

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

    
int team GetClientTeam(client);

    if (!
client) return;

    if(!
IsFakeClient(client))
    {
        
RequestFrame(RFrame_CheckBuyZoneValueclient);
        
        if(
GetRandomInt(1,10) == 1)
        {
            if(
team == 3)
            {
                
char usp[32];
                
                
GetClientWeapon(clientuspsizeof(usp));
                
                if(
StrEqual(usp"weapon_usp_silencer"))
                {
                    
int uspslot GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);
                    
                    if (
uspslot != -1)
                    {
                        
RemovePlayerItem(clientuspslot);
                    }
                    
GivePlayerItem(client"weapon_hkp2000");
                }
            }
        }
    }
}

public 
void RFrame_CheckBuyZoneValue(int client) {
    if (!
IsClientInGame(client) || !IsPlayerAlive(client)) return;

    
int m_iAccount GetEntProp(clientProp_Send"m_iAccount");
    
int team GetClientTeam(client);
    
    
int m_bHasDefuser GetEntProp(clientProp_Send"m_bHasDefuser");
    
int m_bInBuyZone GetEntProp(clientProp_Send"m_bInBuyZone");

    
PrintToServer("%N has m_bInBuyZone value of %d"clientm_bInBuyZone);
    
    if(
m_bInBuyZone == 0)
    {
        if((
m_iAccount 1500) && (m_iAccount 3000))
        {
            
int iWeapon GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY);
            
            if (
iWeapon != -1)
            {
                
RemovePlayerItem(clientiWeapon);
            }
            
            
int rndpistol GetRandomInt(1,3);
            
            switch(
rndpistol)
            {
                case 
1:
                {
                    
GivePlayerItem(client"weapon_p250");
                    
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 300);
                }
                case 
2:
                {
                    if(
team == 3)
                    {
                        
int ctcz GetRandomInt(1,2);
                        
                        switch(
ctcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(client"weapon_fiveseven");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(client"weapon_cz75a");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                    else if(
team == 2)
                    {
                        
int tcz GetRandomInt(1,2);
                        
                        switch(
tcz)
                        {
                            case 
1:
                            {
                                
GivePlayerItem(client"weapon_tec9");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                            case 
2:
                            {
                                
GivePlayerItem(client"weapon_cz75a");
                                
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 500);
                            }
                        }
                    }
                }
                case 
3:
                {
                    
GivePlayerItem(client"weapon_deagle");
                    
SetEntProp(clientProp_Send"m_iAccount"m_iAccount 700);
                }
            }
        }
        else if(
m_iAccount 3000)
        {
            
RemoveNades(client);
            
            
int rndnades GetRandomInt(1,4);
            
            switch(
rndnades)
            {
                case 
1:
                {
                    
GivePlayerItem(client"weapon_flashbang");
                }
                case 
2:
                {
                    
GivePlayerItem(client"weapon_smokegrenade");
                }
                case 
3:
                {
                    
GivePlayerItem(client"weapon_hegrenade");
                }
                case 
4:
                {
                    if(
team == 3)
                    {
                        
GivePlayerItem(client"weapon_incgrenade");
                    }
                    if(
team == 2)
                    {
                        
GivePlayerItem(client"weapon_molotov");
                    }
                }
            }
            if(
team == 3)
            {
                if(
m_bHasDefuser != 0)
                {
                    
GivePlayerItem(client"item_defuser");
                }
            }
        }
    }
}

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

    if (!
client) return;
}

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

    if (!
client) return;
}  

stock void RemoveNades(int client)
{
    while(
RemoveWeaponBySlot(client3)){}
    for(
int i 06i++)
        
SetEntProp(clientProp_Send"m_iAmmo"0_g_iaGrenadeOffsets[i]);
}

stock bool RemoveWeaponBySlot(int clientint iSlot)
{
    
int iEntity GetPlayerWeaponSlot(clientiSlot);
    if(
IsValidEdict(iEntity)) {
        
RemovePlayerItem(clientiEntity);
        
AcceptEntityInput(iEntity"Kill");
        return 
true;
    }
    return 
false;

this return the correct value for me. Just let you know Ive changed team and m_bInBuyZone to local variables instead of global variable and also !IsFakeClient(client) just to test it on myself in a local server
Mathias. 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 03:23.


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