Raised This Month: $ Target: $400
 0% 

Some problem in my plugin (may be Two Dimensional Arrays problem)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ryo89589
Member
Join Date: Aug 2011
Old 06-14-2014 , 14:30   Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
 
new plugin_enabledpip[65][22]
 
public 
plugin_init()
{
 
plugin_enabled register_cvar("amx_betasys""0")
 
register_concmd("amx_addpass""addpass"ADMIN_RCON"<playername|auth> - add specified player as a pass user")
 
register_concmd("amx_delpass""delpass"ADMIN_RCON"<playername|auth> - delete specified player as a pass user")
}
 
public 
client_authorized(id)
 return 
get_pcvar_num(plugin_enabled) ? checkUser(id) : PLUGIN_CONTINUE
 
public delayed_kick(user[])
 
server_cmd("kick #%d"user[0])
 
public 
checkUser(id)
{
 new 
serip[22], userip[22]
 
get_user_ip(0seripcharsmax(serip), 1)
 
get_user_ip(iduseripcharsmax(userip), 1)
 
 if( 
equal(userippip[0], 21) )
  return 
PLUGIN_HANDLED
 
 
new userid[3]
 
userid[0] = get_user_userid(id)
 
set_task(0.1"delayed_kick"0userid1)
 
 return 
PLUGIN_CONTINUE
}
 
public 
addpass(idlevelcid)
{
 if (!
cmd_access(idlevelcid2))
  return 
PLUGIN_HANDLED
 
 
new name[33], ip[22], arg[33]
 
read_argv(1arg32)
 
get_user_name(idnamecharsmax(name))
 
get_user_ip(idipcharsmax(ip))
 
 if( !
equal(argpip[0], 21) )
  
copy(pip[0], charsmax(arg), arg)
 
 return 
PLUGIN_HANDLED
}
 
public 
delpass(idlevelcid)
{
 if (!
cmd_access(idlevelcid2))
  return 
PLUGIN_HANDLED
 
 
new name[33], ip[22], arg[22]
 
read_argv(1argcharsmax(arg))
 
get_user_name(idnamecharsmax(name))
 
get_user_ip(idipcharsmax(ip))
 
 if( 
equal(argpip[0], 21) )
  
copy(pip[0], 0"")
 
 return 
PLUGIN_HANDLED

When I delete an IP, all IP will be affected.
I think "delpass" There are some problems.
Please help me to check for problems. Thank you!

Also, please help me to check all two-dimensional array.
Are there any problems? Thank you very much!

Last edited by ryo89589; 06-14-2014 at 14:32.
ryo89589 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-14-2014 , 16:38   Re: Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #2

I think that this serip is the problem, because you get the IP of everyone (with index 0) and I think this can't be don..
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 06-14-2014 , 17:10   Re: Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
I think that this serip is the problem, because you get the IP of everyone (with index 0) and I think this can't be don..
getting index 0's ip gets the server's ip
can't understand code or whether op wants that or not but it should help
to get all ips use a loop
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
ryo89589
Member
Join Date: Aug 2011
Old 06-14-2014 , 22:04   Re: Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #4

Quote:
Originally Posted by Flick3rR View Post
I think that this serip is the problem, because you get the IP of everyone (with index 0) and I think this can't be don..
Quote:
Originally Posted by aron9forever View Post
getting index 0's ip gets the server's ip
can't understand code or whether op wants that or not but it should help
to get all ips use a loop
Let me give you a new one:
PHP Code:
#include <amxmodx>
#include <amxmisc>
 
#define PLUGIN_NAME "Beta Server System"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "ryo89589"
 
new plugin_enabledpip[65][22]
 
public 
plugin_init()
{
 
register_plugin(PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR)
 
plugin_enabled register_cvar("amx_betasys""0")
 
register_concmd("amx_addpass""addpass"ADMIN_RCON"<playername|auth> - add specified player as a pass user")
 
register_concmd("amx_delpass""delpass"ADMIN_RCON"<playername|auth> - delete specified player as a pass user")
}
 
public 
client_authorized(id)
 return 
get_pcvar_num(plugin_enabled) ? checkUser(id) : PLUGIN_CONTINUE
 
public delayed_kick(user[])
 
server_cmd("kick #%d"user[0])
 
public 
checkUser(id)
{
 new 
serip[22], userip[22]
 
get_user_ip(0seripcharsmax(serip), 1)
 
get_user_ip(iduseripcharsmax(userip), 1)
 
 if( 
equal(useripserip21) || equal(userippip[0], 21) )
  return 
PLUGIN_HANDLED
 
 
new userid[3]
 
userid[0] = get_user_userid(id)
 
set_task(0.1"delayed_kick"0userid1)
 
 return 
PLUGIN_CONTINUE
}
 
public 
addpass(idlevelcid)
{
 if (!
cmd_access(idlevelcid2))
  return 
PLUGIN_HANDLED
 
 
new name[33], ip[22], arg[33]
 
read_argv(1arg32)
 
get_user_name(idnamecharsmax(name))
 
get_user_ip(idipcharsmax(ip))
 
 if( !
equal(argpip[0], 21) )
  
copy(pip[0], charsmax(arg), arg)
 
 return 
PLUGIN_HANDLED
}
 
public 
delpass(idlevelcid)
{
 if (!
cmd_access(idlevelcid2))
  return 
PLUGIN_HANDLED
 
 
new name[33], ip[22], arg[22]
 
read_argv(1argcharsmax(arg))
 
get_user_name(idnamecharsmax(name))
 
get_user_ip(idipcharsmax(ip))
 
 if( 
equal(argpip[0], 21) )
  
copy(pip[0], 0"")
 
 return 
PLUGIN_HANDLED

This adds "equal(userip, serip, 21)" only.

The problem still exists.

When I use amx_addpass added the player as a pass user, this is no problem.
Players can enter the server.

When I add multiple ip in the database, the problems will arise.
Only the latest IP can pass.
Also, when I delete an ip , all pass user's IP will be affect.
So, I think "addpass" & "delpass" There are some problems.
Please help me to check. Thank you!!

Last edited by ryo89589; 06-14-2014 at 23:09.
ryo89589 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 06-14-2014 , 23:27   Re: Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #5

What's the point of using an array with 65 indexes when you only use the first?
Why are you using IP instead of SteamID? Why are you not using the built in functionality of AMXX? That's just stupid.
Your use of charsmax() will defenitely cause index out of bounds errors to frequent your console window.
You're passing 0 as the len for copy() in delpass(), I'm not sure if that'll work. You don't even need that function to clear a string. A simple arrayset() or even nulling the first cell would be fine.
__________________

Last edited by Black Rose; 06-14-2014 at 23:30.
Black Rose is offline
ryo89589
Member
Join Date: Aug 2011
Old 06-15-2014 , 01:10   Re: Some problem in my plugin (may be Two Dimensional Arrays problem)
Reply With Quote #6

Quote:
Originally Posted by Black Rose View Post
What's the point of using an array with 65 indexes when you only use the first?
Why are you using IP instead of SteamID? Why are you not using the built in functionality of AMXX? That's just stupid.
Your use of charsmax() will defenitely cause index out of bounds errors to frequent your console window.
You're passing 0 as the len for copy() in delpass(), I'm not sure if that'll work. You don't even need that function to clear a string. A simple arrayset() or even nulling the first cell would be fine.
Thank you for helping me to check!
1. I used an array with 65 indexes, because I think I should set a limit of 64.
2. I used IP, because I opened a non-steam server.
Therefore, not all players are using SteamID.
3. I do not know the built in functionality of AMXX, so I do not use it.
Please tell me the built in functionality of AMXX. Thank you.
4. I'm sorry, I can not understand. I was in "Two Dimensional Arrays" is very poor.
Please help me correct. Thank you. Thank you. Please.
ryo89589 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 21:17.


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