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

Solved [CSGO] Problem with load Cookie


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-21-2019 , 22:40   [CSGO] Problem with load Cookie
Reply With Quote #1

hi guys!!

how i can load cookie??
i want load cookie when player connect to the server !!

my cod:
PHP Code:
Handle Handle_Cookie_TESTINVALID_HANDLE;
int Int_TEST_Number[MAXPLAYERS+1] = 1;


public 
void OnPluginStart()
{
    
Handle_Cookie_TESTRegClientCookie("test_cookie""test"CookieAccess_Protected);
}

public 
void OnClientPostAdminCheck(int client)
{
    
char Value_Cookie[8];
    
GetClientCookie(clientHandle_Cookie_TESTValue_Cookiesizeof(Value_Cookie));
    
Int_TEST_Number[client] = StringToInt(Value_Cookie);
    
PrintToChat(client"Load Cookie: %d"Int_TEST_Number[client]);
}

public 
int TestMenuHandler(Menu menuMenuAction actionint clientint item)
{
    switch(
action)
    {
        case 
MenuAction_Cancel:
        {
            
delete menu;
        }
        case 
MenuAction_Select:
        {
            
char info[8];
            
GetMenuItem(menuiteminfosizeof(info));
            
SetClientCookie(clientHandle_Cookie_TESTinfo);
            
Int_TEST_Number[client] = StringToInt(info);
            
SetEntProp(clientProp_Send"m_unMusicID"Int_TEST_Number[client]);
            
PrintToChat(client"Save Cookie: %d"Int_Music_Number[client]);
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }
}

void TestMenu(int client)
{
    
Menu menumk = new Menu(TestMenuHandler);
    
menu.SetTitle("TEST MENU: \n \n");
    
menu.AddItem("1""TEST1");
    
menu.AddItem("2""TEST2");
    
menu.AddItem("3""TEST3");
    
menu.AddItem("4""TEST4");
    
menu.AddItem("5""TEST5");
    
menu.ExitButton true;
    
menu.Display(client20);


Last edited by Dr.Mohammad; 03-24-2019 at 22:28.
Dr.Mohammad is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-22-2019 , 04:02   Re: [CSGO] Problem with load Cookie
Reply With Quote #2

Quote:
Originally Posted by Dr.Mohammad View Post
hi guys!!

how i can load cookie??
i want load cookie when player connect to the server !!

my cod:
PHP Code:
Handle Handle_Cookie_TESTINVALID_HANDLE;
int Int_TEST_Number[MAXPLAYERS+1] = 1;


public 
void OnPluginStart()
{
    
Handle_Cookie_TESTRegClientCookie("test_cookie""test"CookieAccess_Protected);
}

public 
void OnClientPostAdminCheck(int client)
{
    
char Value_Cookie[8];
    
GetClientCookie(clientHandle_Cookie_TESTValue_Cookiesizeof(Value_Cookie));
    
Int_TEST_Number[client] = StringToInt(Value_Cookie);
    
PrintToChat(client"Load Cookie: %d"Int_TEST_Number[client]);
}

public 
int TestMenuHandler(Menu menuMenuAction actionint clientint item)
{
    switch(
action)
    {
        case 
MenuAction_Cancel:
        {
            
delete menu;
        }
        case 
MenuAction_Select:
        {
            
char info[8];
            
GetMenuItem(menuiteminfosizeof(info));
            
SetClientCookie(clientHandle_Cookie_TESTinfo);
            
Int_TEST_Number[client] = StringToInt(info);
            
SetEntProp(clientProp_Send"m_unMusicID"Int_TEST_Number[client]);
            
PrintToChat(client"Save Cookie: %d"Int_Music_Number[client]);
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }
}

void TestMenu(int client)
{
    
Menu menumk = new Menu(TestMenuHandler);
    
menu.SetTitle("TEST MENU: \n \n");
    
menu.AddItem("1""TEST1");
    
menu.AddItem("2""TEST2");
    
menu.AddItem("3""TEST3");
    
menu.AddItem("4""TEST4");
    
menu.AddItem("5""TEST5");
    
menu.ExitButton true;
    
menu.Display(client20);

whats the problem? if you are going to ask for help you should state what the problem you are having so we know what to look for
__________________

Last edited by 8guawong; 03-22-2019 at 04:03.
8guawong is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-22-2019 , 05:48   Re: [CSGO] Problem with load Cookie
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
whats the problem? if you are going to ask for help you should state what the problem you are having so we know what to look for
when player connect to the server doesn't load cookie this is my problem.
can you check my cod or help me for other ways??
ask:
how i can load cookie when player connected again to the server??
Dr.Mohammad is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-22-2019 , 07:15   Re: [CSGO] Problem with load Cookie
Reply With Quote #4

Dunno if this is the issue but you should be using OnClientCookiesCached() instead of post admin check.
CliptonHeist is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-22-2019 , 12:17   Re: [CSGO] Problem with load Cookie
Reply With Quote #5

Quote:
Originally Posted by CliptonHeist View Post
Dunno if this is the issue but you should be using OnClientCookiesCached() instead of post admin check.
all right, but don't work for this cod:

PHP Code:
....

    if(
IsClientVIP(client))
    {
        
char Value_Cookie_MusicKit[8];
        
GetClientCookie(clientHandle_Cookie_MusicKitValue_Cookie_MusicKitsizeof(Value_Cookie_MusicKit));
        
Int_Music_Number[client] = StringToInt(Value_Cookie_MusicKit);
        
        if(
Int_Music_Number[client] < || Int_Music_Number[client] > 38 || Int_Music_Number[client] == 2)
        {
            
SetEntProp(clientProp_Send"m_unMusicID"1);
            
Int_Music_Number[client] = 1;
        }
        else
        {
            
SetEntProp(clientProp_Send"m_unMusicID"Int_Music_Number[client]);
        }
        
    }

.... 

Last edited by Dr.Mohammad; 03-22-2019 at 12:18.
Dr.Mohammad is offline
adma
Senior Member
Join Date: Oct 2015
Old 03-23-2019 , 08:13   Re: [CSGO] Problem with load Cookie
Reply With Quote #6

Quote:
Originally Posted by Dr.Mohammad View Post
all right, but don't work for this cod:

PHP Code:
....

    if(
IsClientVIP(client))
    {
        
char Value_Cookie_MusicKit[8];
        
GetClientCookie(clientHandle_Cookie_MusicKitValue_Cookie_MusicKitsizeof(Value_Cookie_MusicKit));
        
Int_Music_Number[client] = StringToInt(Value_Cookie_MusicKit);
        
        if(
Int_Music_Number[client] < || Int_Music_Number[client] > 38 || Int_Music_Number[client] == 2)
        {
            
SetEntProp(clientProp_Send"m_unMusicID"1);
            
Int_Music_Number[client] = 1;
        }
        else
        {
            
SetEntProp(clientProp_Send"m_unMusicID"Int_Music_Number[client]);
        }
        
    }

.... 
When is this code happening? It is best practice to use AreClientCookiesCached if you're not certain that a client's cookies are loaded or not. This way you can define some default behaviour if their cookies aren't cached yet.
adma is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 03-23-2019 , 10:40   Re: [CSGO] Problem with load Cookie
Reply With Quote #7

Use OnClientCookiesCached() forward to begin retrieving the cockies.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-23-2019 , 22:21   Re: [CSGO] Problem with load Cookie
Reply With Quote #8

Quote:
Originally Posted by adma View Post
When is this code happening? It is best practice to use AreClientCookiesCached if you're not certain that a client's cookies are loaded or not. This way you can define some default behaviour if their cookies aren't cached yet.
Quote:
Originally Posted by Dragokas View Post
Use OnClientCookiesCached() forward to begin retrieving the cockies.
thank you guys, so this cod true??

PHP Code:
public void OnClientCookiesCached(int client)
{
    if(
IsClientVIP(client) && AreClientCookiesCached(client))
    {
        
char Value_Cookie_MusicKit[8];
        
GetClientCookie(clientHandle_Cookie_MusicKitValue_Cookie_MusicKitsizeof(Value_Cookie_MusicKit));
        
Int_Music_Number[client] = StringToInt(Value_Cookie_MusicKit);
        
        if(
Int_Music_Number[client] < || Int_Music_Number[client] > 38 || Int_Music_Number[client] == 2)
        {
            
SetEntProp(clientProp_Send"m_unMusicID"1);
            
Int_Music_Number[client] = 1;
        }
        else
        {
            
SetEntProp(clientProp_Send"m_unMusicID"Int_Music_Number[client]);
        }
        
    }

Dr.Mohammad is offline
adma
Senior Member
Join Date: Oct 2015
Old 03-23-2019 , 22:49   Re: [CSGO] Problem with load Cookie
Reply With Quote #9

Quote:
Originally Posted by Dr.Mohammad View Post
thank you guys, so this cod true??

PHP Code:
public void OnClientCookiesCached(int client)
{
    if(
IsClientVIP(client) && AreClientCookiesCached(client))
    {
        
char Value_Cookie_MusicKit[8];
        
GetClientCookie(clientHandle_Cookie_MusicKitValue_Cookie_MusicKitsizeof(Value_Cookie_MusicKit));
        
Int_Music_Number[client] = StringToInt(Value_Cookie_MusicKit);
        
        if(
Int_Music_Number[client] < || Int_Music_Number[client] > 38 || Int_Music_Number[client] == 2)
        {
            
SetEntProp(clientProp_Send"m_unMusicID"1);
            
Int_Music_Number[client] = 1;
        }
        else
        {
            
SetEntProp(clientProp_Send"m_unMusicID"Int_Music_Number[client]);
        }
        
    }

Since you're doing that stuff inside OnClientCookiesCached(), you do not need the AreClientCookiesCached check
adma is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-24-2019 , 01:37   Re: [CSGO] Problem with load Cookie
Reply With Quote #10

Quote:
Originally Posted by adma View Post
Since you're doing that stuff inside OnClientCookiesCached(), you do not need the AreClientCookiesCached check
yeah,
i tested but this code doesn't work, without logs error:
PHP Code:
public void OnClientCookiesCached(int client)
{
    if(
IsClientVIP(client))
    {
        
char Value_Cookie_MusicKit[8];
        
GetClientCookie(clientHandle_Cookie_MusicKitValue_Cookie_MusicKitsizeof(Value_Cookie_MusicKit));
        
Int_Music_Number[client] = StringToInt(Value_Cookie_MusicKit);
        
        if(
Int_Music_Number[client] < || Int_Music_Number[client] > 38 || Int_Music_Number[client] == 2)
        {
            
SetEntProp(clientProp_Send"m_unMusicID"1);
            
Int_Music_Number[client] = 1;
        }
        else
        {
            
SetEntProp(clientProp_Send"m_unMusicID"Int_Music_Number[client]);
        }
        
    }

maybe this is problem for "SetEntProp(client, Prop_Send, "m_unMusicID", Int_Music_Number[client]);" ??

can you help me??
Dr.Mohammad 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:12.


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