Raised This Month: $ Target: $400
 0% 

Simple sockets to get server status


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 12-31-2013 , 04:43   Re: Simple sockets to get server status
Reply With Quote #2

If you're using the function like this:
new variable = get_data("host");
you can't return nothing. You need to return a value.
For example:
Code:
stock get_data(host[]) {     new ip[32], port[10], err;     copy(ip,charsmax(ip),host);     copy(port,charsmax(port),"27015");     if(containi(host,":")!=-1)     strtok(host, ip, charsmax(ip), port, charsmax(port), ':');     new sock = socket_open(ip,str_to_num(port),SOCKET_UDP,err);     if(sock<0 || err)     {         server_print("Socket error");         socket_close(sock);         return 0;     }     new buffer[1500];     copy(buffer,charsmax(buffer),"^xFF^xFF^xFF^xFF^x54Source Engine Query");     socket_send2(sock,buffer,strlen(buffer)+1);     new r = socket_recv(sock,buffer,sizeof(buffer));     socket_close(sock);     if(r<2)     {         server_print("No data");         return 0;     }     return 1 }
Please indent code.
__________________
Black Rose is offline
 



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 10:14.


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