Code Monkey home page Code Monkey logo

raknetmanager's Introduction

RakNet Manager

Plugin for SA:MP Server that allows you to work with RakNet in PAWN.

Required 0.3z-R1 version or newer.

Examples (0.3.7)

RPC

stock SendChatMessage(sender_id, msg[])
{
  new BitStream:bs = BS_New(), RPC_Chat = 101;
  
  BS_WriteValue(bs, RNM_INT16, sender_id, 
                    RNM_INT8, strlen(msg), 
                    RNM_STRING, msg);
                    
  BS_RPC(bs, sender_id, RPC_Chat);
  
  BS_Delete(bs);
}

Packet

stock FakeLostConnectionForPlayer(player_id)
{
  new BitStream:bs = BS_New(), ID_CONNECTION_LOST = 33;
  
  BS_WriteValue(bs, RNM_INT8, ID_CONNECTION_LOST);
  
  BS_Send(bs, player_id);
  
  BS_Delete(bs);
}

Intercept received player's data

new ID_PLAYER_SYNC = 207;
public OnPlayerReceivedPacket(player_id, packet_id, BitStream:bs)
{
   if(packet_id == ID_PLAYER_SYNC)
   {
   new lrkeys, udkeys, sampkeys,
   Float:pos[3], Float:quaternion[4],
   health, armor, weaponid, specialaction,
   Float:speed[3], Float:surfingoffsets[3],
   surfingvehid, animationid, animflags;
    
   BS_IgnoreBits(bs, 8); // packet id
   BS_ReadValue(bs, RNM_UINT16, lrkeys,
   				 RNM_UINT16, udkeys,
   			     RNM_UINT16, sampkeys,
   				 RNM_FLOAT, pos[0],
   				 RNM_FLOAT, pos[1],
   				 RNM_FLOAT, pos[2],
   				 RNM_FLOAT, quaternion[0],
   				 RNM_FLOAT, quaternion[1],
                    RNM_FLOAT, quaternion[2],
                    RNM_FLOAT, quaternion[3],
                    RNM_UINT8, health,
                    RNM_UINT8, armor,
                    RNM_UINT8, weaponid,
                    RNM_UINT8, specialaction,
                    RNM_FLOAT, speed[0],
   				 RNM_FLOAT, speed[1],
   				 RNM_FLOAT, speed[2],
   				 RNM_FLOAT, surfingoffsets[0],
   				 RNM_FLOAT, surfingoffsets[1],
   				 RNM_FLOAT, surfingoffsets[2],
   				 RNM_UINT16, surfingvehid,
   				 RNM_INT16, animationid,
   				 RNM_INT16, animflags);
   				  
   printf("lrkeys %d udkeys %d sampkeys %d\n" \
          "pos %.2f %.2f %.2f\n" \
   	   "quaternion %.2f %.2f %.2f %.2f\n" \
   	   "health %d\n" \
   	   "armor %d\n" \
   	   "weaponid %d\n" \
   	   "specialaction %d\n" \
   	   "speed %.2f %.2f %.2f\n" \
   	   "surfingoffsets %.2f %.2f %.2f\n" \
   	   "surfingvehid %d\n" \
   	   "anim %d flags %d",
   	   lrkeys, udkeys, sampkeys,
          pos[0], pos[1], pos[2],
          quaternion[0], quaternion[1], quaternion[2], quaternion[3],
          health, armor, weaponid, specialaction,
          speed[0], speed[1], speed[2],
   	   surfingoffsets[0], surfingoffsets[1], surfingoffsets[2],
          surfingvehid, animationid, animflags
   	   );
   }
   return 1;
}

Intercept received player's RPC

new RPC_Chat = 101;
public OnPlayerReceivedRPC(player_id, rpc_id, BitStream:bs)
{
	if(rpc_id == RPC_Chat) 
	{
	new message[512], len;
	
	BS_ReadValue(bs, RNM_UINT8, len,
					 RNM_STRING, message, len);
					 
	printf("[%d]: %s", player_id, message);
	}
	
	return 1;
} 

raknetmanager's People

Contributors

katursis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.