Help for script
#1

Hello
I want to write a script that automatically changes the position actor return to its previous position, if such a thing is please please help me.
Reply
#2

uppppp
Reply
#3

You can use this:
PHP код:
GetActorPos(actoridFloat:XFloat:YFloat:Z
to get the actor position then you need to verify if their position is correct if not.
PHP код:
SetActorPos(actoridFloat:XFloat:YFloat:Z
to set their position, you can change Float:X, Float:Y, and Float:Z to their default actor position.
Reply
#4

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
You can use this:
PHP код:
GetActorPos(actoridFloat:XFloat:YFloat:Z
to get the actor position then you need to verify if their position is correct if not.
PHP код:
SetActorPos(actoridFloat:XFloat:YFloat:Z
to set their position, you can change Float:X, Float:Y, and Float:Z to their default actor position.
This should be in the game mode init to write?
There is a chance you give an example?
Reply
#5

if you meant that if an actor is being spawned?
PHP код:
//actor variable
new Actor[MAX_ACTOR]; //assuming you have set the MAX_ACTOR to a ideal number 
PHP код:
//Place this on gamemodinit
Actor[0] = CreateActor(01605.82201829.062510.52514.3929//spawns actor CJ infront of Las Venturas Hospital 
you won't need to get the actors position coz it will spawn on your specified location.
but
if you meant that if an actor is moved, by i.e players, objects, or bullet?
PHP код:
//Place this somewhere when you try to update the actors, i.e timers, callbacks, etc
new Float:axFloat:ayFloat:azFloat:angle;
GetActorPos(Actor[0], axayaz);
GetActorFacingAngle(Actor[0], angle);
if(
ax != 1605.8220 || ay != 1829.0625//or you could add Z, which is not ideal since a little movement on the ground changes the actors x and y axis
SetActorPos(actorid1605.82201829.062510.5251); //respawns actor CJ infront of Las Venturas Hospital
SetActorFacingAngle(Actor[0], 4.3929); 
This will keep the actor teleported back to it's location every time the timer reaches its interval or when you update each actor on the server. In theory

NOTE:
I don't know if there is somewhat a function like
PHP код:
AddStaticVehicleEx(modelidFloat:spawn_xFloat:spawn_yFloat:spawn_zFloat:z_anglecolor1color2respawn_delayaddsiren=0); 
That respawns the actor at a given time.
Reply
#6

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
if you meant that if an actor is being spawned?
PHP код:
//actor variable
new Actor[MAX_ACTOR]; //assuming you have set the MAX_ACTOR to a ideal number 
PHP код:
//Place this on gamemodinit
Actor[0] = CreateActor(01605.82201829.062510.52514.3929//spawns actor CJ infront of Las Venturas Hospital 
you won't need to get the actors position coz it will spawn on your specified location.
but
if you meant that if an actor is moved, by i.e players, objects, or bullet?
PHP код:
//Place this somewhere when you try to update the actors, i.e timers, callbacks, etc
new Float:axFloat:ayFloat:azFloat:angle;
GetActorPos(Actor[0], axayaz);
GetActorFacingAngle(Actor[0], angle);
if(
ax != 1605.8220 || ay != 1829.0625//or you could add Z, which is not ideal since a little movement on the ground changes the actors x and y axis
SetActorPos(actorid1605.82201829.062510.5251); //respawns actor CJ infront of Las Venturas Hospital
SetActorFacingAngle(Actor[0], 4.3929); 
This will keep the actor teleported back to it's location every time the timer reaches its interval or when you update each actor on the server. In theory

NOTE:
I don't know if there is somewhat a function like
PHP код:
AddStaticVehicleEx(modelidFloat:spawn_xFloat:spawn_yFloat:spawn_zFloat:z_anglecolor1color2respawn_delayaddsiren=0); 
That respawns the actor at a given time.
Actor position is read from the database and I define a variable called actorrespawn I gave him a second time, but nothing happens Please help me.

PHP код:
public OnActorLoad() {
    new 
rows cache_num_rows(),
        
count 0,
        
string[30],
        
Sname[30],
        
SLib[30],
        
SAnimName[30];
    for(new 
i=0rowsi++) {
        
ActorData[i][ValidActor] = 1;
        
ActorData[i][aID] = cache_get_field_content_int(i,"ID");
        
ActorData[i][ActorSkin] = cache_get_field_content_int(i,"SkinID");
        
ActorData[i][aX] = cache_get_field_content_float(i,"X");
        
ActorData[i][aY] = cache_get_field_content_float(i,"Y");
        
ActorData[i][aZ] = cache_get_field_content_float(i,"Z");
        
ActorData[i][aA] = cache_get_field_content_float(i,"A");
        
ActorData[i][NameColor] = cache_get_field_content_int(i,"namecolor");
        
        
cache_get_field_content(i,"anim_lib",SLib);
        
strcpy(ActorData[i][Actor_AnimLib],SLib,50);
        
cache_get_field_content(i,"anim_name",SAnimName);
        
strcpy(ActorData[i][Actor_AnimName],SAnimName,50);
        
cache_get_field_content(i,"Name",Sname);
        
strcpy(ActorData[i][aName],Sname,24);
        
format(string,sizeof(string),"{FFFFFF}%s(%i)",ActorData[i][aName],ActorData[i][aID]);
        
ActorData[i][ActorText] = CreateDynamic3DTextLabel(stringActorData[i][NameColor],ActorData[i][aX],ActorData[i][aY],ActorData[i][aZ]+1.0510.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0);
        
ActorData[i][ActorPlayer] = CreateActor(ActorData[i][ActorSkin],ActorData[i][aX],ActorData[i][aY],ActorData[i][aZ],ActorData[i][aA]);
        
count += 1;
        
ApplyActorAnimation(ActorData[i][ActorPlayer],ActorData[i][Actor_AnimLib],ActorData[i][Actor_AnimName], 4.010000);
    }
    if(
count == 0) print("ACTOR SYSTEM: No actors found the in the SQL.");
    else 
printf("ACTOR SYSTEM: Total %i actors loaded.",count);
    return 
true;

PHP код:
SetTimer("ActorRespawn"1000false); 
PHP код:
forward ActorRespawn();
public 
ActorRespawn()
{
    for(new 
0MAX_ACTORSi++) {
        new 
Float:axFloat:ayFloat:azFloat:angle;
        
GetActorPos(iaxayaz);
        
GetActorFacingAngle(iangle);
        if(
ax != ActorData[i][aX] || ay != ActorData[i][aY]) 
            {
            
SetActorPos(iActorData[i][aX], ActorData[i][aY], ActorData[i][aZ]); 
            
SetActorFacingAngle(iActorData[i][aA]);
            
sql_LoadAllActors();
            }
    }

Reply
#7

upppp help me
Reply
#8

plz help me not work script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)