Raised This Month: $32 Target: $400
 8% 

Warn Other Players!


Post New Thread Reply   
 
Thread Tools Display Modes
Relaxing
AlliedModders Donor
Join Date: Jun 2016
Location: White Plains
Old 07-19-2018 , 06:01   Re: Warn Other Players!
Reply With Quote #11

Code:
            if(warnedTimes[iPlayer] == 0){                 warnedTimes[iPlayer]++;             } else if(warnedTimes[iPlayer] == 1){                 warnedTimes[iPlayer]++;             } else if(warnedTimes[iPlayer] == 2){                 warnedTimes[iPlayer]++;
What's the purpose of this?!
__________________
Relaxing is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 06:51   Re: Warn Other Players!
Reply With Quote #12

Those are cringe lines..
LemoNSK is offline
LemoNSK
Member
Join Date: Jul 2018
Location: Criminal Underworld
Old 07-19-2018 , 06:52   Re: Warn Other Players!
Reply With Quote #13

Quote:
Originally Posted by edon1337 View Post
Here's some optimization you could do to the code:
1.
PHP Code:
            if(warnedTimes[iPlayer] == 0){
                
warnedTimes[iPlayer]++;
            } else if(
warnedTimes[iPlayer] == 1){
                
warnedTimes[iPlayer]++;
            } else if(
warnedTimes[iPlayer] == 2){
                
warnedTimes[iPlayer]++; 
Instead of if() and else if() you could use switch().

2. You should specify a HUD time because default is 12 seconds
PHP Code:
set_hudmessage(02550, -1.0, -1.6
3.
Player name can't be longer than 32 characters, so you can use [32].
PHP Code:
idName[50
Thank you for your optimalization.
LemoNSK is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 07:06   Re: Warn Other Players!
Reply With Quote #14

Now that I noticed, these lines are completely redundant,
PHP Code:
            if(warnedTimes[iPlayer] == 0){
                
warnedTimes[iPlayer]++;
            } else if(
warnedTimes[iPlayer] == 1){
                
warnedTimes[iPlayer]++;
            } else if(
warnedTimes[iPlayer] == 2){
                
warnedTimes[iPlayer]++; 
Should be just
PHP Code:
warnedTimes[iPlayer]++ 
Also this part of the code is wrong
PHP Code:
server_cmd("amx_kick #%d ^"Warned too many times!^""get_user_userid(iPlayer));
                new 
msg[255], idName[50];
                
get_user_name(ididNamecharsmax(idName));
                
format(msgcharsmax(msg), "Administrator %s warned player %s ^nReason: %s ^nWarns: 3/3 ^nPlayer has been kicked from the server!"
idNameszTargetNameszReasonwarnedTimes[iPlayer]); 
                
warnedTimes[iPlayer] = 0
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-07-2020 , 12:11   Re: Warn Other Players!
Reply With Quote #15

edon gave you some suggestions. Unapproved until you improve your code.
__________________
HamletEagle is offline
Reply


Thread Tools
Display Modes

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 04:33.


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