Actor
#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


Messages In This Thread
Actor - by KinderClans - 27.08.2018, 13:13
Re: Actor - by victory88 - 31.08.2018, 00:08
Re: Actor - by Shinja - 31.08.2018, 00:11
Re: Actor - by victory88 - 31.08.2018, 00:13
Re: Actor - by SapMan - 31.08.2018, 02:45
Re: Actor - by Dayrion - 31.08.2018, 12:48
Re: Actor - by KinderClans - 31.08.2018, 13:00
Re: Actor - by Dayrion - 31.08.2018, 15:03
Re: Actor - by KinderClans - 31.08.2018, 16:08
Re: Actor - by Dayrion - 31.08.2018, 16:24

Forum Jump:


Users browsing this thread: 2 Guest(s)