Raised This Month: $ Target: $400
 0% 

Scripting help needed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kapeel
Junior Member
Join Date: Aug 2009
Old 08-01-2009 , 09:33   Scripting help needed
Reply With Quote #1

Hello guys,

I am new here and i am going to design my first plugin,it will not be public,it will be for my own clan.

I want to make a plugin which will work like high ping kicker.Of course it will not do what the high ping kicker does.I just want to open an http connection after a specific interval of time and once when the server will start and will shut down.

Is there any function i can use to open a http connection?

Are there any libs for that?Please suggest so and also guide me about calling a function when a server is started and stopped.
kapeel is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 09:37   Re: Scripting help needed
Reply With Quote #2

You can use the sockets module for the http request and display data in a MOTD window.
__________________
Bugsy is offline
kapeel
Junior Member
Join Date: Aug 2009
Old 08-01-2009 , 09:40   Re: Scripting help needed
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
You can use the sockets module for the http request and display data in a MOTD window.
no dude, i am trying to make a plugin which will open http connection to the website server of clan. The url will carry the variables using GET method. Then the script on webserver will update data in the database so that it can be viewable on website.

Thats what i am trying to do

I don't think that MOTD window will be helpful for this.
kapeel is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 09:42   Re: Scripting help needed
Reply With Quote #4

Ok, then:

You can use the sockets module for the http request and display data in a MOTD window.
__________________
Bugsy is offline
kapeel
Junior Member
Join Date: Aug 2009
Old 08-01-2009 , 09:46   Re: Scripting help needed
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Ok, then:

You can use the sockets module for the http request and display data in a MOTD window.
can you please explain it?as i said before, i am new to all this,but i can understand the basics because i am php programmer
kapeel is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 09:50   Re: Scripting help needed
Reply With Quote #6

What does the http request look like, I will put it together for you.

Code:
GET /what_does_this_need_to_be HTTP/1.1
Host: www.google.com
__________________
Bugsy is offline
kapeel
Junior Member
Join Date: Aug 2009
Old 08-01-2009 , 10:17   Re: Scripting help needed
Reply With Quote #7

firstly, thanks for your support.

I want to know how can i get the server name, players on server and map which is running on server through variables.

i am searching madly for this thing,but i can't get it anywhere.please help me.
kapeel is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 10:25   Re: Scripting help needed
Reply With Quote #8

I don't know what you mean by get players but I assume get a list of player names?

Use "/info" in chat to show info.

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new g_pHostname;
new 
g_iMaxPlayers;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /info" "ShowInfo" );
    
    
g_pHostname get_cvar_pointer"hostname" );
    
g_iMaxPlayers get_maxplayers();
}

public 
ShowInfoid )
{
    static 
iPlayers32 ] , iNum szAllPlayers1024 ] , iLen szName33 ];
    static 
szMap16 ];
    static 
szHostname128 ];
    
    
//Read map name into szMap var
    
get_mapnameszMap 15 );
    
    
//Read hostname from cvar "hostname"
    
get_pcvar_stringg_pHostname szHostname 127 );
    
    
//Get all players currently connected to server
    
get_playersiPlayers iNum );
    
    
//Loop through names retrieved with get_players() and get each players name and add it to one
    //large string variable in "name1, name2, name3" format
    
iLen 0;
    for ( new 
iNum i++ )
    {
        
get_user_nameiPlayers] , szName 32 );
        
iLen += formatexszAllPlayersiLen ] , 1024-iLen "%s, " szName );
    }
    
szAllPlayersiLen-] = 0;
    
    
//Display to user
    
client_printid print_chat "Server name: %s" szHostname );
    
client_printid print_chat "Map name: %s" szMap );
    
client_printid print_chat "Players [%d/%d]: %s" iNum g_iMaxPlayers szAllPlayers );

__________________

Last edited by Bugsy; 08-01-2009 at 10:34.
Bugsy is offline
kapeel
Junior Member
Join Date: Aug 2009
Old 08-01-2009 , 10:33   Re: Scripting help needed
Reply With Quote #9

thanks for your help

but i also want to know number of player and total slots.

thanks for the above code,but can u help me in putting all the info in different variables?
kapeel is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 10:35   Re: Scripting help needed
Reply With Quote #10

Edited above code to show number of players along with slots. Everything is in variables, what do you mean?

Code:
Server name: test server 1.1
Map name: de_dust2
Players [1/10]: bugsy
__________________
Bugsy is offline
Reply



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 22:07.


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