Raised This Month: $ Target: $400
 0% 

Check if admin online & antispam


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lawnmoverman
Member
Join Date: Jan 2017
Old 01-28-2017 , 12:48   Check if admin online & antispam
Reply With Quote #1

Can someone add a function to check if any of admins are online & th last time /calladmin has been used at least 10 minutes ago! And if I can get player who called name in the link.

PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("Call admin""0.1""Lawnmoverman")
    
register_concmd("say /calladmin","cmdCallAdmin"0" - Will call call admin to join the server, if he is not sleeping.")
}

public 
cmdCallAdmin(id)
{    
if ((!
admin_is_online) && (passed_at_least_10_minutes)) { // Something like this
    
show_motd(id"http://www.nozgaming.eu/calladmin.php?name=PLAYER_NAME_HERE"// <--
    
return PLUGIN_HANDLED
}
else {
client_print(idprint_chat"There are admins online, or someone has already called an admin. Do not abuse!")
return 
PLUGIN_HANDLED
}

Lawnmoverman is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-29-2017 , 09:31   Re: Check if admin online & antispam
Reply With Quote #2

Please ask if you have any questions. I did a lot of changes.

Code:
#include <amxmodx> #include <amxmisc> new Float:gNextCall[33]; new gpcvarCooldown; new gpcvarURL; public plugin_init() {     register_plugin("Call admin", "0.1", "Lawnmoverman")     register_clcmd("say", "clcmdSay", 0, "")     gpcvarCooldown = register_cvar("calladmin_cooldown", "10.0"); // In minutes     gpcvarURL = register_cvar("calladmin_url", "http://hostname.sub/calladmin.php?message="); } public clcmdSay(id) {     new Message[64];     read_args(Message, charsmax(Message));     remove_quotes(Message);     Message[10] = 0;     if ( ! equali(Message[1], "calladmin") )         return PLUGIN_CONTINUE;     new Float:GameTime = get_gametime();     if ( gNextCall[id] > GameTime ) {         client_print(id, print_chat, "You used this command recently. Please wait %.0fm, %ds to use this command again.", (gNextCall[id] - GameTime) / 60.0, floatround(gNextCall[id] - GameTime) % 60);         return PLUGIN_HANDLED;     }     gNextCall[id] = GameTime + get_pcvar_float(gpcvarCooldown) * 60;     new Admins[32], Adminsnum = OnlineAdmins(Admins);     if ( Adminsnum ) {         new PlayerName[32];         get_user_name(id, PlayerName, charsmax(PlayerName));         for ( new i ; i < Adminsnum ; i++ ) {             client_print(Admins[i], print_chat, "[Call Admin] %s called an admin with the following message:", PlayerName);             client_print(Admins[i], print_chat, "[Call Admin] %s", Message[11]);         }         client_print(id, print_chat, "An admin is online and has been notified.");         return PLUGIN_HANDLED;     }     new URL[192];     get_pcvar_string(gpcvarURL, URL, charsmax(URL));     add(URL, charsmax(URL), Message[11]);     show_motd(id, URL)     return PLUGIN_HANDLED; } stock OnlineAdmins(Admins[32]="") {     new Players[32], Playersnum, Adminsnum;     get_players(Players, Playersnum);     for ( new i ; i < Playersnum ; i++ ) {         if ( is_user_admin(Players[i]) ) {             Admins[Adminsnum] = Players[i];             Adminsnum++;         }     }     return Adminsnum; }
__________________

Last edited by Black Rose; 01-29-2017 at 09:31.
Black Rose is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 01-29-2017 , 16:04   Re: Check if admin online & antispam
Reply With Quote #3

I will try it out tommorow. You should get this plugin approved as theres nothing similar.
Lawnmoverman is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 01-30-2017 , 14:11   Re: Check if admin online & antispam
Reply With Quote #4

Solved! Everything works Black Rose ! As I said you should get this plugin approved. Thanks!
Lawnmoverman is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-30-2017 , 14:18   Re: Check if admin online & antispam
Reply With Quote #5

I won't.
I do think there already are plugins out there like this. I also think that this is not a complete solution. I would like to see one with the PHP and preferably some kind of IM service. Anything that enables real-time communication in a simple way.
__________________
Black Rose is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 01-31-2017 , 07:05   Re: Check if admin online & antispam
Reply With Quote #6

After some research I got to the point, that including IM apis would be too difficult for user to install everything and not all would work with free hostings. I decided to provide only email notification as basically everybody have an email and almost every of the are synchronized with smartphone. I will provide smtp method with possibility to use custom email and simple mail function that will work also if your php is compiled without smtp module. The simple method will display as sender your hosting account username. Although smtp method can be requested without extra costs on almost every hosting provider. Thats all to keep install and script as easier as just like upload to server and go.

Last edited by Lawnmoverman; 01-31-2017 at 08:02.
Lawnmoverman is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-07-2017 , 16:12   Re: Check if admin online & antispam
Reply With Quote #7

Here we are:


.sma:
PHP Code:
// Big thanks to Black Rose for this plugin
#include <amxmodx>
#include <amxmisc>

new Float:gNextCall[33];

new 
gpcvarCooldown;
new 
gpcvarURL;

public 
plugin_init() {

    
register_plugin("Call admin""1.0""Lawnmoverman & Black Rose")

    
register_clcmd("say""clcmdSay"0""

    
gpcvarCooldown register_cvar("calladmin_cooldown""10.0"); // Set anti flood protection in minutes
    
gpcvarURL register_cvar("calladmin_url""http://www.nozgaming.eu/calladmin.php?token=1234567890123&message="); // Edit your url & token
}

public 
clcmdSay(id) {

    new 
Message[64];
    
read_args(Messagecharsmax(Message));
    
remove_quotes(Message);
    
Message[10] = 0;

    if ( ! 
equali(Message[1], "calladmin") )
        return 
PLUGIN_CONTINUE;

    new 
Float:GameTime get_gametime();

    if ( 
gNextCall[id] > GameTime ) {
        
client_printc(id"!t[Call Admin] !gYou used this command recently. Please wait %.0fm, %ds to use this command again.", (gNextCall[id] - GameTime) / 60.0floatround(gNextCall[id] - GameTime) % 60); 
        return 
PLUGIN_HANDLED;
    }

    
gNextCall[id] = GameTime get_pcvar_float(gpcvarCooldown) * 60;

    new 
Admins[32], Adminsnum OnlineAdmins(Admins);

    if ( 
Adminsnum ) {

        new 
PlayerName[32];
        
get_user_name(idPlayerNamecharsmax(PlayerName));

        for ( new 
Adminsnum i++ ) {
            
client_printc(Admins[i], "!t[Call Admin]!g %s called an admin with the following message:"PlayerName);
            
client_printc(Admins[i], "!t[Call Admin]!g %s"Message[11]);
        }

        
client_printc(id"!t[Call Admin]!g An admin is online and has been notified.");
        return 
PLUGIN_HANDLED;
    }

    new 
URL[192];
    
get_pcvar_string(gpcvarURLURLcharsmax(URL));
    
add(URLcharsmax(URL), Message[11]);
    
show_motd(idURL)

    return 
PLUGIN_HANDLED;
}

stock OnlineAdmins(Admins[32]="") {

    new 
Players[32], PlayersnumAdminsnum;
    
get_players(PlayersPlayersnum);

    for ( new 
Playersnum i++ ) {
        if ( 
is_user_admin(Players[i]) ) {
            
Admins[Adminsnum] = Players[i];
            
Adminsnum++;
        }
    }

    return 
Adminsnum;
}

// Colour Chat
client_printc(index, const text[], any:...)
{
    new 
szMsg[128];
    
vformat(szMsgsizeof(szMsg) - 1text3);
    
    
replace_all(szMsgsizeof(szMsg) - 1"!g""^x04");
    
replace_all(szMsgsizeof(szMsg) - 1"!n""^x01");
    
replace_all(szMsgsizeof(szMsg) - 1"!t""^x03");
    
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _index);
    
write_byte(index);
    
write_string(szMsg);
    
message_end();



.php:
PHP Code:
<?php
// CallAdmin.php
// Edit and upload this file to your web host, and use with 'Call admin' AMX Mod X plugin by Lawnmoverman & Black Rose

// Admin emails ( note the commas )
$to '[email protected][email protected][email protected]';

// Subject
$subject 'cs.nozgaming.eu - calladmin';

// From ( we don't want our messages to get in spam folder )
$headers[] = 'From: NOZGAMING.EU - DAEMON <[email protected]>';

// We are using html, do not chnage these, unless you want to use a plain text in your emails
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';

// Use your unique value, specify it also in .sma script, along with url, and recompile! ( !!!It is important to change this!!! )
$check_token '1234567890123';

// Edit messages to fit your needs
// Remember that gmail supports almost nothing for css ( it is better to use div for all content, to give 100% support )
// You can also decide to use plain text
// Note the structure:

// - EMAIL START >
// $message_top
// MESSAGE SENT BY PLAYER
// $message_bottom
// < EMAIL END -

$message_top '
<html>
<head>
<title>NIGHT OVER ZERO CS 1.6 [PUB] - CALLADMIN</title>
</head>
<body>
<div style="margin: 0; background-color: #6d6a5a; font-family: Verdana; font-size: 12px; color: #ffffff;">
<br>
<center><img src="http://www.nozgaming.eu/motd/logo.gif"><br>
<b><font color="#ff9138">NIGHT OVER ZERO CS 1.6 [PUB] - CALLADMIN</font></b><br><br>
Admin assistance required on server!<br>
Calladmin function were executed on server.<br>Please join the server as soon as you can!<br><br>
Player sent the following message:<br><br>
-x-x-x-<br>
'
;

$message_bottom '
<br>-x-x-x-<br><br>
This message is sent from automatic daemon! Please, do not reply to this address!<br>
<a href="http://www.nozgaming.eu" target="_blank" style="color: #6ebcff;">&copy; www.nozgaming.eu</a><br><br>
</div>
</center>
</body>
</html>
'
;

// Confirm page ( will be showed in players motd on server, use html here )
$confirm_page '
<html>
<head>
<style type="text/css">
body {
  margin: 0;
  background-color: #6d6a5a;
  font-family: Verdana;
  font-size: 12px;
  color: #ffffff;
}
a, a:active, a:visited {
  color: #6ebcff;
  text-decoration: none;
}
a:hover {
  color: #ff9138;
  text-decoration: underline;
}
</style>
</head>
<body>
<center><img src="http://www.nozgaming.eu/motd/logo.gif" /><br>
<b><font color="#ff9138">NIGHT OVER ZERO CS 1.6 [PUB] - CALLADMIN</font></b><br><br>
-x-x-x-<br>
<font color="#6ebcff"><b>[Call Admin]</b></font> All admins have been alerted, someone will join as soon as he can! :P<br>
-x-x-x-<br><br>
&copy; nozgaming.eu<br>
<a href="http://www.nozgaming.eu" target="_blank">www.nozgaming.eu</a><br><br>
</center>
</body>
</html>
'
;

// Error page ( if someone calls this script from browser, use html here )
$error_page '
<html>
<head>
<meta http-equiv="refresh" content="10; url=http://www.nozgaming.eu/" />
<title>NIGHT OVER ZERO CS 1.6 [PUB] - CALLADMIN</title>
<style type="text/css">
body {
  margin: 0;
  background-color: #6d6a5a;
  font-family: Verdana;
  font-size: 12px;
  color: #ffffff;
}
a, a:active, a:visited {
  color: #6ebcff;
  text-decoration: none;
}
a:hover {
  color: #ff9138;
  text-decoration: underline;
}
</style>
</head>
<body>
<center><img src="http://www.nozgaming.eu/motd/logo.gif" /><br>
<b><font color="#ff9138">NIGHT OVER ZERO CS 1.6 [PUB] - CALLADMIN</font></b><br><br>
-x-x-x-<br>
<font color="#6ebcff"><b>ERROR:</b></font> You can not execute this function outside of server! :P<br>
-x-x-x-<br><br>
&copy; nozgaming.eu<br>
<a href="http://www.nozgaming.eu" target="_blank">www.nozgaming.eu</a><br><br>
</center>
</body>
</html>
'
;

// There is nothing to edit below
if( isset( $_GET['token'] ) && ( $_GET['token'] == $check_token ) ) {
  
$message_player $_GET['message'];
  
mail$to$subject$message_top $message_player $message_bottomimplode"\r\n"$headers ) );
  print 
$confirm_page;
}
else {
  print 
$error_page;
  die;
}
?>


Works good, all tested!

Last edited by Lawnmoverman; 02-07-2017 at 16:50.
Lawnmoverman 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 20:48.


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