public void GetNativeCallFromPlayer(Client player, string salt, ulong hash, NativeArgument returnType, Action <object> callback, params object[] arguments) { var obj = new NativeData(); obj.Hash = hash; obj.ReturnType = returnType; salt = Environment.TickCount.ToString() + salt + player.NetConnection.RemoteUniqueIdentifier.ToString() + DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds.ToString(); obj.Id = salt; obj.Arguments = ParseNativeArguments(arguments); var bin = SerializeBinary(obj); var msg = Server.CreateMessage(); msg.Write((int)PacketType.NativeCall); msg.Write(bin.Length); msg.Write(bin); _callbacks.Add(salt, callback); player.NetConnection.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, GetChannelIdForConnection(player)); }
public void GetNativeCallFromPlayer(NetConnection player, string identifier, ulong hash, NativeArgument returnType, Action <object> callback, params object[] arguments) { var obj = new NativeData(); obj.Hash = hash; obj.ReturnType = returnType; obj.Id = identifier; var list = new List <NativeArgument>(); foreach (var o in arguments) { if (o is int) { list.Add(new IntArgument() { Data = ((int)o) }); } else if (o is uint) { list.Add(new UIntArgument() { Data = ((uint)o) }); } else if (o is string) { list.Add(new StringArgument() { Data = ((string)o) }); } else if (o is float) { list.Add(new FloatArgument() { Data = ((float)o) }); } else if (o is bool) { list.Add(new BooleanArgument() { Data = ((bool)o) }); } else if (o is Vector3) { var tmp = (Vector3)o; list.Add(new Vector3Argument() { X = tmp.X, Y = tmp.Y, Z = tmp.Z, }); } else if (o is LocalPlayerArgument) { list.Add(new LocalPlayerArgument()); } else if (o is OpponentPedHandleArgument) { list.Add((OpponentPedHandleArgument)o); } } obj.Arguments = list.ToList(); var bin = SerializeBinary(obj); var msg = Server.CreateMessage(); msg.Write((int)PacketType.NativeCall); msg.Write(bin.Length); msg.Write(bin); _callbacks.Add(identifier, callback); player.SendMessage(msg, NetDeliveryMethod.ReliableOrdered, GetChannelIdForConnection(player)); }