Is there a wayh to replace this code bellow to simple callback’s like in .LUA scripts
_RESOURCE.LUA
client_scripts {
'stasiek_phone_client.net.dll'
}
server_scripts{
'stasiek_phone_server.net.dll'
}
CLIENT
public MainClient()
{
EventHandlers.Add("stasiek_phone:GetUserPhoneNumbers", new Action<dynamic>(GetUserPhoneNumbers));
TriggerServerEvent("stasiek_phone:GetUserPhoneNumbers");
}
private void GetUserPhoneNumbers(dynamic numbers)
{
for (int i = 0; i < (dynamic)numbers.Count; i++)
{
myPhoneNumbers.Add(numbers[i].ToString());
}
}
SERVER
public MainServer()
{
EventHandlers.Add("stasiek_phone:GetUserPhoneNumbers", new Action<Player>(GetUserPhoneNumbers));
}
private void GetUserPhoneNumbers([FromSource] Player source)
{
Exports["ghmattimysql"].execute($"SELECT * FROM stasiek_phone_simcards WHERE owner = 'steam:" + source.Identifiers["steam"] + "';", new Action<dynamic>((result) =>
{
if (result != null)
{
List<string> numbers = new List<string>();
for(int i = 0; i < (dynamic)result.Count; i++)
{
numbers.Add(result[i].number.ToString());
}
source.TriggerEvent("stasiek_phone:GetUserPhoneNumbers", numbers);
}
}));
}