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

black screen for lannies


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 12-08-2017 , 10:15   black screen for lannies
Reply With Quote #1

black screen for lannies
it is useful for gaming cafe!

Issue#1
Quote:
its removing all ips suppose
Player1 connected with 192.168.0.12 reponse = no bool
Player2 connected with 192.168.0.12 response = bool true = black screen works
Player3 connected with 192.168.0.12 respone = bool true = black screen works
indra connected with 192.168.0.12 reponse = bool true = black screen works
i am disconnected, it removes all ips
now i am again connected with 192.168.0.12 response = no bool = no black screen
but there are already two players playing with 192.168.0.12
Issue#2
Quote:
sometime normal players gets black screen i don't know why

Question
Quote:
how can i remove only disconnected user ip from Trie
Question
Quote:
how can i compare first three octet of ip
Thanks

PHP Code:

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "Black screen for lannies"
#define VERSION "0.2"
#define AUTHOR "26-{indra}"

#define TASK_BLACK 1111

new Trie:g_IPs;
new 
bool:black_screen[33] = false;
new 
glo_screenfade;

public 
plugin_init() 
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
register_event"DeathMsg""death""a" );
    
RegisterHamHam_Spawn"player""Playerspawn");
    
register_event("TextMsg""spec_mode""bd""2&Spec_Mode")
    
register_event("SendAudio""end_round","a""2=%!MRAD_terwin""2=%!MRAD_ctwin");
    
glo_screenfade get_user_msgid("ScreenFade");
    
g_IPs TrieCreate();
}

public 
plugin_end()
    
TrieDestroy(g_IPs);


public 
client_putinserver(id)
{
    static 
szIP[16], szName[33];
    
get_user_ip(idszIPcharsmax(szIP), 1);
    
get_user_name(idszNamecharsmax(szName) );
    
    if (
TrieKeyExists(g_IPsszIP))
    {
        
black_screen[id] = true;
        
log_to_file"LAN_IP.log""Name : %s | IP: %s",szName,szIP);
    }
    else
        
TrieSetCell(g_IPsszIP1);
}


public 
client_disconnect(id)
{
    
/*
    the issue is here
    its removing all ips suppose 
    Player1 connected with 192.168.0.12 reponse = no bool
    Player2 connected with 192.168.0.12  response = bool true = black screen
    Player3 connected with 192.168.0.12 respone = bool true = black screen
    indra connected with 192.168.0.12    reponse = bool true = black screen
    now i am disconnected, it removes all ips 
    now i am again connected with 192.168.0.12 response = no bool = no black screen
    but there are all already two players playing 192.168.0.12
    
    */
    
    
static szIP[16];
    
get_user_ip(idszIPcharsmax(szIP), 1); 
    
TrieDeleteKey(g_IPsszIP); // needs to fix here 
    
server_print("g_IPs : %s | %s",g_IPs,szIP)
    
black_screen[id] = false;
    if(
task_exists(TASK_BLACK))
        
remove_task(id TASK_BLACK);
}

public 
death()
{
    new 
id read_data(2);
    if(
black_screen[id])
    { 
        
set_task(0.5,"show_black",id+TASK_BLACK_,_"b");
    }
}

public 
spec_mode(id)
{
    if (
black_screen[id])
        
client_cmd(id"spec_mode 3");
    return 
PLUGIN_CONTINUE;
}


public 
show_black(id)
{
    
id -= TASK_BLACK;
    if(
black_screen[id])
    {
        
message_begin(MSG_ONE glo_screenfade, {0,0,0}, id)
        
write_short(1<<12)
        
write_short(1<<12)
        
write_short(0x0004)
        
write_byte(0)
        
write_byte(0)
        
write_byte(0)
        
write_byte(255)
        
message_end()
        
set_hudmessage(02550, -1.0, -1.006.012.0);
        
show_hudmessage(id"[LAN] If You are not playing at Gaming Cafe with Same IP then reconnect.");
        
client_cmd(id"spec_mode 3");
    }
}

//resetting two times to fixed the issue at end round and spawn
public end_round()
{
    new 
players[32], pnum
    get_players
(playerspnum)
    for(new 
0pnumi++) 
    { 
        if(
black_screen[i])
        {
            
remove_task(TASK_BLACK);
            
message_begin(MSG_ONE glo_screenfade, {0,0,0}, i)
            
write_short(1<<12)
            
write_short(1<<12)
            
write_short(0x0004)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
message_end()
        }
        
    }
}

public 
Playerspawn(id)
{
    if(
black_screen[id])
    {
        
message_begin(MSG_ONE glo_screenfade, {0,0,0}, id)
        
write_short(1<<12)
        
write_short(1<<12)
        
write_short(0x0004)
        
write_byte(0)
        
write_byte(0)
        
write_byte(0)
        
write_byte(0)
        
message_end()
        
remove_task(id TASK_BLACK);
    }

Attached Files
File Type: sma Get Plugin or Get Source (black_screen.sma - 500 views - 3.3 KB)

Last edited by indraraj striker; 12-08-2017 at 11:11.
indraraj striker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-08-2017 , 22:11   Re: black screen for lannies
Reply With Quote #2

2. Search. When looking for a function to delete a key from a trie, try searching the API (or better yet, the include file that is used for Tries) for a function that does that.
3. Store only what you need to compare. If doing less than a full IP, you'd need to do a counter for each matching subset which can easily be done with the data for that Trie key.
__________________
fysiks is online now
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 12-09-2017 , 02:27   Re: black screen for lannies
Reply With Quote #3

2.
Quote:
when first player is disconnected
L 12/09/2017 - 126:08: IP 192.168.0.12 is deleted
when second player is disconnected
L 12/09/2017 - 126:08: the following IP 192.168.0.12 is already deleted
PHP Code:
get_user_ip(idszIPcharsmax(szIP), 1); 
    if( 
TrieDeleteKey(g_IPs ,szIP))  // needs to fix here 
    
{
       
log_to_file("black_screen.log","IP %s is deleted",szIP);
    }
    else
    {
      
log_to_file("black_screen.log","the following IP %s is already deleted",szIP);
    } 
this will remove his ip from trie am i right
TrieDeleteKey(g_IPs ,szIP)

and this will clear all the ip from trie am i right
TrieClear( g_IPs )

so i am using deletekey but why its removing all user ips from Trie
it should work like this
Player1 is connected with 192.168.0.12
Player2 is connected with 192.168.0.12
Player3 is connected with 192.168.0.12
Indra is connected with 192.168.0.12
now indra is disconnected
Deletekey should remove only ip address of indra not all ips
I am totally messed up -_- and i think i have to use TrieSetArray as i want to remove only specific user ip
3. i will search
Thanks

Last edited by indraraj striker; 12-09-2017 at 02:28.
indraraj striker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-09-2017 , 04:09   Re: black screen for lannies
Reply With Quote #4

I misspoke, you need to do the counting regardless of the number of IP digits you use. When someone connects, add their IP to the Trie with a value 1. When the next person connects, check if their IP already exists, if yes, get the value and add 1 (and set your flag).

This is a really simple implementation and won't properly handle all corner conditions.

Have you search the forums for this idea? It's been requested several times before.
__________________
fysiks is online now
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 12-09-2017 , 04:19   Re: black screen for lannies
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
I misspoke, you need to do the counting regardless of the number of IP digits you use. When someone connects, add their IP to the Trie with a value 1. When the next person connects, check if their IP already exists, if yes, get the value and add 1 (and set your flag).

This is a really simple implementation and won't properly handle all corner conditions.

Have you search the forums for this idea? It's been requested several times before.
if i add their ip in trie and dont remove when they disconnect it will create issue
what if i reconnect 3 times it will say this ip is already in trie and set bool is true

PHP Code:
    static szIP[16], szName[33];
    
get_user_ip(idszIPcharsmax(szIP), 1); //get his ip
    
get_user_name(idszNamecharsmax(szName) );
    
    if (
TrieKeyExists(g_IPsszIP)) //if the ip is exist in trie
    
{
        
black_screen[id] = true;  //set this bool true
        
log_to_file"LAN_IP.log""Name : %s | IP: %s",szName,szIP); //log purpose
    
}
    else
        
TrieSetCell(g_IPsszIP1); // if the ip isnt exist in trie it will add 
i will search
Thanks anyway
indraraj striker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-09-2017 , 17:55   Re: black screen for lannies
Reply With Quote #6

Clearly, you don't understand what I said. Also, after thinking about it, this method won't work reliably. You would need to loop through all players when a new player connects and check to see if they have a similar IP and set your boolean accordingly (for both the connecting player and all other players that had the similar IP.

Also,
Quote:
Originally Posted by fysiks View Post
Have you search the forums for this idea? It's been requested several times before.
__________________
fysiks is online now
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 12-10-2017 , 01:52   Re: black screen for lannies
Reply With Quote #7

fysiks okay
Thanks for the idea!
indraraj striker 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 22:19.


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