View Single Post
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-26-2013 , 01:02   Re: AMX Show IP - Last The Best Show IP
Reply With Quote #4

About code :

- Don't create variables in loops.
- Cache array cells values in a variable (players[i] in your code).
- I think you should add bot("c") (and hltv("h")) filter(s) to get_players.
- Cache map name in a global variable and retrieve it only once in plugin_init, at least don't retrieve it on each loop iteration
- Command seems to be only for connected players, so either use register_clcmd, either make different checks (check id against 0 so you can know if command comes from server when server is dedicated server).
- Remove not used define ( #define STR_LEN 32 )
- This is really minor, but you could lower following arrays sizes like this :
szIp : 22, steamid 21
- Also, use charsmax when you need to pass the max len you want to fill a string array, it will prevent some mistakes as the one you did :
Code:
        new name[32];         new szIp[32];         new steamid[32];         new mapname[32];         new team[32];         get_user_frags(players[i])         get_user_name(players[i], name, 31)         get_user_ip(players[i], szIp, 31, 0)         get_user_authid(players[i], steamid , 31)         get_mapname(mapname, 31)         get_user_team(players[i], team, 18)
There either array should be 19 size, either you should pass 31 in get_user_team native
So do like this :
Code:
get_user_team(player, team, charsmax(team)
And then if one day you edit team size at the variable declaration, you won't need to check where you have used it to update max len.


I think this is all.



About plugin, it is redundant, unapproved.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline