#1

So, i have a dynamic actor creating system, and this is how i load them (i use sqlite database):

pawn Код:
stock LoadActor()
{
    new query[356], DBResult:qresult, count = 0, value[128],string[356],Float:xim,Float:yim,Float:zim,Float:aim,TextActor[356],ActorName[32],
    AVW,ActorSkin2,adurum3;
    if(!db_query(DB: ActorDatabase, "SELECT * FROM `ActorDB`"))
    {
        format(query,sizeof(query),"CREATE TABLE IF NOT EXISTS `ActorDB` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT,`ActorName` TEXT,`ActorVirtualWorld`INTEGER ,`ActorX` TEXT,`ActorA` TEXT,`ActorY` TEXT,`ActorZ` TEXT,`Skin` INTEGER ,`ActorActive` INTEGER ,`Text` TEXT)");
        db_query(ActorDatabase,query);
    }
    else
    {
        qresult = db_query(ActorDatabase,  "SELECT * FROM `ActorDB`");
        count = db_num_rows(qresult);
        for(new a=0;a<count;a++)
        {
            if(count >= 1 && count <= MAX_ACTORS)
            {
                db_get_field_assoc(qresult, "ActorX", value, 20);       xim = floatstr(value);
                db_get_field_assoc(qresult, "ActorY", value, 20);       yim = floatstr(value);
                db_get_field_assoc(qresult, "ActorZ", value, 20);       zim = floatstr(value);
                db_get_field_assoc(qresult, "ActorA", value, 20);       aim = floatstr(value);
                db_get_field_assoc(qresult, "Text",string,356);          format(TextActor,356,string);
                db_get_field_assoc(qresult, "ActorName",string,35);    format(ActorName,32,string);
                db_get_field_assoc(qresult, "ActorVirtualWorld", value, 20);    AVW = strval(value);
                db_get_field_assoc(qresult, "Skin", value, 20);         ActorSkin2 = strval(value);
                db_get_field_assoc(qresult, "ActorActive", value, 20);      adurum3 = strval(value);
                if(adurum3 == 1)
                {
                ActorCreate(ActorName,Actor_AI,TextActor,ActorSkin2,xim,yim,zim,aim,AVW,adurum3);
                Actor_AI++;
                }
                db_next_row(qresult);

            }
        }
        db_free_result(qresult);
    }
    return 1;
}
Everything works, actors are created and loaded.

I have a stock to check if player is a range of an actor:

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;
}
Problem: I created an actor called "Boxer", so i made in this way:

OnPlayerKeyStateChange:

pawn Код:
if (IsPlayerInRangeOfActor(playerid, Boxer))
{
 ShowPlayerFooter(playerid, "Hi!", 5000);
}
But doesn't work. Do i have to load actor name from db first? How?
Reply
#2

PHP код:
stock IsPlayerInRangeOfActor(playeridactoridFloat:radius 5.0
IsPlayerInRangeOfActor requires three arguments, playerid, actorid and the radius/distance in a float value.


PHP код:
if (IsPlayerInRangeOfActor(playeridBoxer))
{
 
ShowPlayerFooter(playerid"Hi!"5000);

When you check the actor range you do not provide a third argument, range. e.g (playerid, Boxer, 13.0)

Also under ShowPlayerFooter add SendClientMessageToAll(-1, "test");
Reply
#3

Quote:
Originally Posted by victory88
Посмотреть сообщение
PHP код:
stock IsPlayerInRangeOfActor(playeridactoridFloat:radius 5.0
IsPlayerInRangeOfActor requires three arguments, playerid, actorid and the radius in a float value.


PHP код:
if (IsPlayerInRangeOfActor(playeridBoxer))
{
 
ShowPlayerFooter(playerid"Hi!"5000);

When you check the actor range you do not provide a the third argument, range. e.g (playerid, Boxer, 13.0)
You are wrong, by using Float:radius = 5.0, he is setting a default value to 5.0, it means if he dont enter a specific radius, it will be 5.0
Reply
#4

Quote:
Originally Posted by Shinja
Посмотреть сообщение
You are wrong, by using Float:radius = 5.0, he is setting a default value to 5.0, it means if he dont enter a specific radius, it will be 5.0
I did not know that, very well.
Reply
#5

Exactly what do you want to do or what is the problem?
Reply
#6

You need to show the full command and not 3 lines of it.
Reply
#7

Quote:
Originally Posted by SapMan
Посмотреть сообщение
Exactly what do you want to do or what is the problem?
I explained in the first post.

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
You need to show the full command and not 3 lines of it.
Full command of what? There is no command. I use "IsPlayerInRangeOfActor" in OnPlayerKeyStateChange, which is connected to KEY_YES command. (Means if player press Key_Yes he will interact with the autor).
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
I explained in the first post.



Full command of what? There is no command. I use "IsPlayerInRangeOfActor" in OnPlayerKeyStateChange, which is connected to KEY_YES command. (Means if player press Key_Yes he will interact with the autor).
That:
Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Problem: I created an actor called "Boxer", so i made in this way:

(In a command: )

pawn Код:
if (IsPlayerInRangeOfActor(playerid, Boxer))
{
 ShowPlayerFooter(playerid, "Hi!", 5000);
}
But doesn't work. Do i have to load actor name from db first? How?
You are talking about a command, can we see the code?
If I'm still wrong, debug ur code.
Reply
#9

Ah sorry, i mistyped. There is no command, that code is on OnPlayerKeyStateChange.
Reply
#10

Where do you defined `Boxer`? What value do you attribute to `Boxer`? Where ? Can you show the code?
Creating a variable called `Boxer` will not refer to the actor with the label "Boxer" by the way..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)