Skip to content

Commit

Permalink
Add NpcPedPositionData
Browse files Browse the repository at this point in the history
  • Loading branch information
soccermitchy committed Dec 20, 2016
1 parent bb19a9c commit 075ac69
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gtaserver.core/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ private void HandleClientIncomingData(Client client, NetIncomingMessage msg)
var pedData = Util.DeserializeBinary<PedData>(msg.ReadBytes(len));
if (pedData != null)
{
var pluginPedData = GameEvents.NpcPedDataUpdate(client, pedData);
if (!pluginPedData.ContinueServerProc) return;
pedData = pluginPedData.Data;

pedData.Id = msg.SenderConnection.RemoteUniqueIdentifier;
}
SendToAll(pedData, PacketType.NpcPedPositionData, false, client);
Expand Down
21 changes: 21 additions & 0 deletions gtaserver.core/PluginAPI/Events/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,26 @@ public static PluginResponse<VehicleData> NpcVehicleDataUpdate(Client c, Vehicle
}
return result;
}


public static List<Func<Client, PedData, PluginResponse<PedData>>> OnNpcPedDataUpdate
= new List<Func<Client, PedData, PluginResponse<PedData>>>();

public static PluginResponse<PedData> NpcPedDataUpdate(Client c, PedData p)
{
var result = new PluginResponse<PedData>()
{
ContinuePluginProc = true,
ContinueServerProc = true,
Data = p
};
foreach (var f in OnNpcPedDataUpdate)
{
result = f(c, p);
if (!result.ContinuePluginProc) return result;
p = result.Data;
}
return result;
}
}
}

0 comments on commit 075ac69

Please sign in to comment.