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

UID Not working propely


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-13-2017 , 14:12   UID Not working propely
Reply With Quote #1

Hello everyone ! I have a problem with my plugin...
If I want to take everyone from a team from the server is not taking everyone... Sometimes random... Also no errors in console
Here is the code:

PHP Code:
for (int i 1i<=MaxClientsi++)    
{
    new 
uID1 GetClientUserId(i);
    
ServerCommand("sm_blind #%d 220"uID1);        
    if(
IsClientInGame(i) && GetClientTeam(i) == 2// Sets the T Team model 
    
{  
            
g_bCommandUsedDayZom[i] = true;
            
SetEntityMoveType(iMOVETYPE_NONE);
            
SDKHook(iSDKHook_WeaponEquipOnWeaponEquip);
            
SetEntityModel(i"models/player/kuristaja/zombies/gozombie/gozombie.mdl");
            
SetEntityHealth(i4000);
            new 
uID GetClientUserId(i);
            
ServerCommand("sm_blind #%d 250"uID);        
    } 

Also if you want to see the SDKHook :

PHP Code:
public Action:OnWeaponEquip(clientweapon

    
decl String:sWeapon[32]; 
    
GetEdictClassname(weaponsWeaponsizeof(sWeapon)); 
     
    if( !
StrEqual(sWeapon"weapon_knife") ) 
    { 
        if( 
GetClientTeam(client) == CS_TEAM_T
        { 
            return 
Plugin_Handled
        }
        if( 
GetClientTeam(client) == CS_TEAM_CT && g_bCommandUsedDayHNS[client]) 
        { 
            return 
Plugin_Handled
        }
    } 
     
    return 
Plugin_Continue

cristian20042 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-13-2017 , 15:29   Re: UID Not working propely
Reply With Quote #2

Are you sure there are no errors?
You shouldn't call GetClientUserId(i) before you check to see if they are in game.
Mitchell is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-13-2017 , 18:00   Re: UID Not working propely
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
Are you sure there are no errors?
You shouldn't call GetClientUserId(i) before you check to see if they are in game.
^ this

I mean the documentation for GetClientUserId even warns you that it will throw an error

Quote:
if the client is not connected or the index is invalid
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 12-14-2017 , 13:28   Re: UID Not working propely
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
Are you sure there are no errors?
You shouldn't call GetClientUserId(i) before you check to see if they are in game.
I tried everything i can do... I tried to define it before but it will be for all players...

I really don't know what to do...

Quote:
Originally Posted by Powerlord View Post
^ this

I mean the documentation for GetClientUserId even warns you that it will throw an error
They are in-game and connected...

Last edited by cristian20042; 12-14-2017 at 13:29.
cristian20042 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 12-14-2017 , 19:59   Re: UID Not working propely
Reply With Quote #5

Your loop goes over every possible client index. Unless your server is always full, then some index in that range will not have a connected client. When you call GetClientUserId on such an index, you will get an error in your SM logs and your script will immediately stop.
Fyren 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 19:02.


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