C winsock et serveur HalfLife Counter-strike

VoLc0m Messages postés 40 Date d'inscription vendredi 10 janvier 2003 Statut Membre Dernière intervention 24 avril 2008 - 31 mars 2003 à 19:31
Viper31 Messages postés 96 Date d'inscription mardi 2 avril 2002 Statut Membre Dernière intervention 7 août 2005 - 1 avril 2003 à 22:03
voila ca fé a peu pres 3 mois ke je tente désesperement, grace a winsock, en C, de faire un bot ki va prendre les info d'un serveur counter strike, pour connaitre le nombres de player, la map... g u le manuel pour faire ce genre de programme, comme koi il fo envoyer 4bits255, le serveur répon par 1 bit 255... mé bon g tjs pas reussi, chui ptet un nb, un boulé mé bon tjs po reussi :'((
alors si kk'un a déja fé ca, ca seré vraiment super sympa dm'expliker car la je déprime :((

jvous remercie d'avance.

4 réponses

Viper31 Messages postés 96 Date d'inscription mardi 2 avril 2002 Statut Membre Dernière intervention 7 août 2005
1 avril 2003 à 00:33
HALF LIFE SDK !
0
Viper31 Messages postés 96 Date d'inscription mardi 2 avril 2002 Statut Membre Dernière intervention 7 août 2005
1 avril 2003 à 21:26
Extrait de la SDK :

=========================================
Game servers will answer the following messages:
Messages are sent to the server by sending 4 consecutive bytes of 255 (32-bit integer -1) and then the string command followed by a zero byte to terminate it

===========
"ping"
Server responds with a single byte code ASCII 'j'
===========
"info"
Server responds with the following packet:
(int32) -1
(byte) ASCII 'C' (info response, S2A_INFO)
(string) net address of server
(string) name of the host / server
(string) name of the map
(string) game directory (i.e. valve/)
(string) Game description (e.g. "half-life multiplay")
(byte) active client count
(byte) maximum clients allowed
(byte) protocol version (currently 7)
===========
"players"
Server responds with the following packet:
(int32) -1
(byte) ASCII 'D' (players response, S2A_PLAYER)
(byte) active client count

for each active client
(byte) client number / index
(string) player name
(int32) client's frag total
(float32) client's total time in-game
===========
"rules"
Server responds with the following packet:
(int32) -1
(byte) ASCII 'E' (rules response, S2A_RULES)
(int16) number of rules

for each rule
(string) rule name
(string) rule value

=========================
Deja , faut apprendre a lire l anglais :

BYTES =/= BITS !!!!!!

BYTE = OCTET (=un caractere ascii)

Donc ca ok , ensuite ils disent faut envoyé une serie de 4 octet a 255 (int à -1) ==> ca correspond a un fanion de debut de trame ou je m'y conné pas :) !!

Ensuite il dise , faut envoye le "string" dont tu ve la reponse , a savoir , "info" ou " player" !

puis tu boucle la trame avec un octet a 0 !!

en clair :

t 'envoye -1-1-1-1 / "info" / 0 ! c'est clair

mais kan je met -1 et 0 , c'est pas "-1" et "0" que tu dois envoyer ! c'est les bits ...

donc si j'ai bien compris moi aussi , tu peux essayer de faire ca :

char buffer[10];
sprintf(buffer,"%c%c%c%cinfo%c",(char)-1,(char)-1,(char)-1,(char)-1,(char)0);

et t envoie char * buffer par le socket et ta plus qu a attendre la reponse !! apres galere toi pour interpreter le resultat ^^ !

ca c qu'il demande ...

apres pour les puriste du C , me fusilier par pour ce que j'ai pu ecrire ... ^^ ( ... %c" ... (char)0 )
0
VoLc0m Messages postés 40 Date d'inscription vendredi 10 janvier 2003 Statut Membre Dernière intervention 24 avril 2008
1 avril 2003 à 21:35
nan mé c bon merci kan meme :)
je c lire anglais et le prob c t pas ca, ca jlavé deja fé depuis lgtps :) il fallé passer mon socket en DGRAM =)
voila le pb :D la ca marche c bon ! :p
0
Viper31 Messages postés 96 Date d'inscription mardi 2 avril 2002 Statut Membre Dernière intervention 7 août 2005
1 avril 2003 à 22:03
Bah forcement ^^ , c de l UDP ;) pas du TCP ! donc datagram.

tu pourrai poster un bout de code pour voir ??
0
Rejoignez-nous