I already seen this in lua… My problem is that GetEntityPlayerIsFreeAimingAt have 2 argoument in c# and for some reason I did something wrong and I can’t get the entity ID , stay always as 0 and I also get some error.
I’m not able to translate this lua code in C#. I will add DoesEntityExist(targetPed) to be sure that exist, but I have not fixed . Thx anyway gadolinium. If someone find the answer thx very much :).
Thx Flatracer with this we solved the problem the ID requested is the local ID, sometimes when ask the int Player you should put the server id and sometimes the local , is not clear. Anyway the only part missing is now how to convert this entity into a Ped. If anyone need the code is this for now:
public void GetPed()
{
int entity = 0;
bool aimEntity = API.GetEntityPlayerIsFreeAimingAt(API.PlayerId(), ref entity );
//player is aiming
if (aimEntity == true)
{
//the entity exist (is aiming an entity)
if (API.DoesEntityExist(entity ) == true)
{
if (API.IsEntityAPed(entity ) == true)
{
if (API.IsEntityDead(entity) == false)
{
Debug.WriteLine("Aiming to alive Ped " + entity.ToString());
}
else
{
Debug.WriteLine("Aiming to a death Ped " + entity.ToString());
}
}
else {
if (API.IsEntityDead(entita) == false)
{
Debug.WriteLine("Aiming to an alive entity (not Ped) " + entity.ToString());
}
else
{
//miro a una entita' che non e' un ped
Debug.WriteLine("Aiming to a death entity (not Ped) " + entity.ToString());
}
}
}
else {
Debug.WriteLine("Is aiming but not an entity'");
}
}
else
{
Debug.WriteLine("false");
}
Just need to know how to convert that entity now to a ped.
A perfect I confused probably sending from the client to the server “the server ID to have a list of the server ID” .
But I see now most of the times you use the local ID on client side :D! Is more clear now :D.
when you have an entity, you can use the model of the entity for know what is it : entity.Model.isPed() or entity.Model.isVehicle() ect…
when you know what it is you can use the handle of the entity for instance the wanted object (in your case it’s a ped) :
Ped p = new Ped(entity.Handle);
ps: don’t forget that the handle are only client side and not networked. if you want to network it you have to use the native PedToNet and NetToPed
Thx very much 304bl, I have a question, the conversion Ped p = new Ped(entity.Handle); is better than Ped ped = entity as Ped; ? I mean that Handle thing help in some way? Just to know to improve my skill and the code .
A ok thx very much :D! This could help for the mysql part :D. Soo entity.Handle could be good to store data and p will be a referece for the ped to use function :D.
no lol , handle shouldn’t be store in any database , for the simple reason that when you close the game and start it again the handle will change for everything , a handle is an ID who is given by the game to an object you create , when that object is delete by you or the game the handle is release and will be use by another object who need to be create.
when i mean store it , it was in your script in a tab of ped you create or liist for use them.
ps : p is just a short name i use you can call it whatever you want.