#1

So i have this stock took fron extended actor functions:

pawn Код:
stock IsPlayerInRangeOfActor(playerid, actorid, Float:radius = 5.0)
{
    new
        Float:x,
        Float:y,
        Float:z;

    if (GetActorPos(actorid, x, y, z))
    {
        return IsPlayerInRangeOfPoint(playerid, radius, x, y, z) && GetPlayerVirtualWorld(playerid) == GetActorVirtualWorld(actorid);
    }
    return 0;
}
I have an actor which is id 1, how i can use it this stock to send a message to player? Ex: You're near actor ID 1.

Thanks.
Reply
#2

I hope I will help you by that example code:
PHP код:
public OnPlayerUpdate(playerid)
{
    if(
IsPlayerInRangeOfActor(playeridactorid))
        
SendClientMessage(playerid, -1"You are near actor");
    return 
1;
}
stock IsPlayerInRangeOfActor(playeridactoridFloat:radius 5.0)
{
    new
        
Float:x,
        
Float:y,
        
Float:z;
    
GetActorPos(actoridxyz);
    if(
IsPlayerInRangeOfPoint(playeridradiusxyz) && GetPlayerVirtualWorld(playerid) == GetActorVirtualWorld(actorid))
        return 
1;
    return 
0;

I will be grateful if you + my reputation (in case if I helped you..)
Reply
#3

Thanks, gonna test it now and let you know.
Reply
#4

Tried, seems to work but i have a problem.

I have currently 2 actors, one at LSPD and one at Los Santos Hospital. Each actor should open a different dialog.

Example: LSPD Actor should open Cops Dialog (already scripted) and LS Hospital actor should open cure menu (did this too).

My question is, how to make it? I was thinking to do with OnPlayerKeyStateChange, by using IsPlayerInRangeOfActor, but i don't know how. (I want the dialog should appear when player is near an actor and presses a key).

In short words:

2 actors should open 2 different dialogs, how i can do this with actorid?
Reply
#5

The real problem would come to me as poor system design. You should have your own include to handle actor data.

Код:
enum ACTORINFO {
    Float:Actor_X,
    Float:Actor_Y,
    Float:Actor_Z,
    Float:Actor_FA,
    Actor_Type,
    Actor_Dialog,
}

g_ActorData[MAX_ACTORS][ACTORINFO];

CreateSpecialActor(Float:x, Float:y, Float:z, Float:fa, Float:AType, Float:ADialog)
DeleteSpecialActor(actorid)
GetSpecialActorData(actorid, &Float:x, &Float:y, &Float:z, &Float:fa, &AType, &ADialog)
UpdateSpecialActorDat(actorid, Float:x, Float:y, Float:z, Float:fa, AType, ADialog)
I always do it the same way, create enum and variable then list the functions you know you will need. In this case you know how many actors are possible so you array size needs to be the same as that. That way you can simply reference any array index by actorid.
Reply
#6

I already do. I have a separate fs which handles all actor data. Creating deleting editing and so on. Do you mind helping me?
Reply
#7

Then add the data you need to your actor data to store a dialog id pretty easy. You should also never need to this.

Код:
public OnPlayerUpdate(playerid) 
{ 
    if(IsPlayerInRangeOfActor(playerid, actorid)) 
        SendClientMessage(playerid, -1, "You are near actor"); 
    return 1; 
}
Use dynamic areas.
Reply
#8

No i just need help with what i asked, please.
Reply
#9

I just told you what to do... how hard is that ?
Reply
#10

I dont wanna edit current system since i have already everything done. If you don't wanna help me i'll wait another one. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)