AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Warn Other Players! (https://forums.alliedmods.net/showthread.php?t=309239)

LemoNSK 07-18-2018 15:23

Warn Other Players!
 
2 Attachment(s)
- Warn other players! -


Hello, I've made my code to warn a certain players. You check it and also re-write it if you want. If you want, you can also rate my work. (I know that many of you already know how this all works)

- What it does -
Basically you warn player and after being warned three times, player will be automatically kicked from the server and a message on the screen will be written to all players that the player has been kicked. That's all.


- The End -

I hope this code helps some scripters and can be used in some future plugins you'll be creating. I hope you like it.
Please, excuse me, this is my first code post! If something is wrong, lemme know!
This code is for at least intermediate scripters, i don't suggest it to newbies.

Celena Luna 07-18-2018 15:23

Re: Warn Other Players!
 
Remove the amxx file

LemoNSK 07-18-2018 15:25

Re: Warn Other Players!
 
Quote:

Originally Posted by Celena Luna (Post 2604605)
Remove the amxx file

Thanks for making me aware :)

Relaxing 07-18-2018 16:48

Re: Warn Other Players!
 
As a newbie I would suggest you to REwrite the whole projecrjt.

LemoNSK 07-18-2018 16:52

Re: Warn Other Players!
 
Quote:

Originally Posted by Relaxing (Post 2604646)
As a newbie I would suggest you to REwrite the whole projecrjt.

I've corrected it .. you just have to know at least some basics of AMXX.. I meant to give people a good idea for their servers, that's everything..

Rivotril 07-18-2018 17:05

Re: Warn Other Players!
 
Why don't you use a stock inside the plugin instead of giving a download for the .inc for the colors?

LemoNSK 07-18-2018 17:15

Re: Warn Other Players!
 
Quote:

Originally Posted by Rivotril (Post 2604654)
Why don't you use a stock inside the plugin instead of giving a download for the .inc for the colors?

Thank you for your reply :) But I don't want to do that.

edon1337 07-18-2018 17:55

Re: Warn Other Players!
 
Already made:
https://forums.alliedmods.net/showthread.php?t=186670
https://forums.alliedmods.net/showpo...&postcount=550

LemoNSK 07-19-2018 00:03

Re: Warn Other Players!
 
Ah, ok. At least I tried ;)

edon1337 07-19-2018 05:28

Re: Warn Other Players!
 
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


Relaxing 07-19-2018 06:01

Re: Warn Other Players!
 
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?!

LemoNSK 07-19-2018 06:51

Re: Warn Other Players!
 
Those are cringe lines..

LemoNSK 07-19-2018 06:52

Re: Warn Other Players!
 
Quote:

Originally Posted by edon1337 (Post 2604737)
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. :)

edon1337 07-19-2018 07:06

Re: Warn Other Players!
 
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


HamletEagle 04-07-2020 12:11

Re: Warn Other Players!
 
edon gave you some suggestions. Unapproved until you improve your code.


All times are GMT -4. The time now is 20:43.

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