Ban Player from Menu
I am trying to make a menu with fixed ban types.. like swearing, i made the menu with some samples but its not working.. Can someone help me with this?
Code:
public BPlayerMenu0(id){ |
Re: Ban Player from Menu
PHP Code:
You already send the player name in szName trough the menu, no need to get it again. AdminName is an IP address, obviously. |
Re: Ban Player from Menu
Code:
public BPlayerMenu0(id){ |
Re: Ban Player from Menu
Use "player" as the index in the get_user_ip native. Of course, make sure the player is connected first. You already have the name saved in szName from the menu option, no need for get_user_name there.
Use tempid as the userid in the amx_ban command ("%s" should be "#%d"). //You can also use num_to_str instead of formatex. |
Re: Ban Player from Menu
Now it's almost working like it supposed to, but still something is wrong
Here is the code: Code:
public BPlayerMenu0(id){ |
Re: Ban Player from Menu
You shouldn't be using the id from get_players in your menu data. You should be using the userid (from get_user_userid()) because if someone leaves after you open the menu and another person joins, they will get that same id and you might ban someone that wasn't supposed to be banned.
Also, to use the "#" in the amx_ban command requires the userid (from get_user_userid()), not the entity id (from get_players()). So, I think you only need to make the following changes: Code:
|
Re: Ban Player from Menu
Now I can't compile it..
Error: Argument type mismatch (argument 1) on line xy .. The line which contains this: new szUserId = str_to_num(get_user_userid(tempid)) and also: Error: Argument type mismatch (argument 3) on line xy .. The line with this: menu_additem(menu, szName, szUserId, 0); |
Re: Ban Player from Menu
Quote:
You need to convert it to a string in order to use it with menu_additem. You need num_to_str, not str_to_num. Quote:
|
Re: Ban Player from Menu
Fixed above. Since I was basing it on his original code, it wasn't as obvious to me at the time. Had I written it from scratch, it would have been much easier.
|
| All times are GMT -4. The time now is 17:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.