Screen Spawn Script

msmalik681

OpenBOR Developer
Staff member
here is a script to spawn relative to screen with entity alias and forced direction last 2 options are optional


Code:
void spawnscreen(void vName, float fX, float fZ, void Alias, int iDirection)
{
   //spawnscreen (Generic spawner with alias and relative to screen)
   //Spawns entity next to caller.
   //vName: Model name of entity to be spawned in.
   //fX: X location adjustment.
   //fZ: Y location adjustment.
        //fY: Z location adjustment.
   void self = getlocalvar("self"); //Get calling entity.
   void vSpawn; //Spawn object.


   clearspawnentry(); //Clear current spawn entry.
   setspawnentry("name",vName); //Acquire spawn entity by name.
   
   vSpawn = spawn(); //Spawn in entity.


   changeentityproperty(vSpawn, "position",openborvariant("xpos")+fX, openborvariant("ypos")+fZ, 0); //Set spawn location.
   if(iDirection){changeentityproperty(vSpawn, "direction", iDirection);} //Set direction.
   if(Alias){changeentityproperty(vSpawn, "name", Alias);} //Set Alias to spawned entity
   changeentityproperty(vSpawn, "parent", self);
   return vSpawn; //Return spawn.
}
 
Hello msmalik681  :)

I need use your script to make a npc ( When player hits it ) spawn a text entity in the center of the screen.

Iam script noob...sorry ...

How can i use your script? Where do i put this codes?
 
hey kdo to use this just make a new document in your scripts folder name it whatever you want for this example lets call it "scripts.c" then in you entity header of the entity that will use the script add "data/scripts/scripts.c" then just call the function within a animation with "@cmd spawnscreen "entity_name" x z" this is the minimum needed variables you can leave the alias and direction if you want to.

Extra note the entity that will be spawned to screen should have some things added to their header data.

subject_to_screen 0
subject_to_minz 0
subject_to_maxz 0
subject_to_gravity 0 #I am guessing this is floating text or something
facing 1 #if you dont want it to face right pick one of the other options.
setlayer 999999999 #only set it this high if you want it to display above everything else
 
I tryed  that but engine chrashes....

I named this script as screen, i made a  document screen.c in the scripts folder , i put the @cmd spawnscreen "mission" 1 1 in the Spawnner animation line and i put in the header of the entity spawnner the script  data/scripts/screen.c  but didnt works.

Is there missing something on the spawnner antity header line data/scripts/screen.c?    I mean somthing like this  first part of the scrip:  animationscript      data/scripts/script.c

:(

 
Hey msmalik681 i tryed again but without sucess.... so i had an idea and seems it works but need some adjustments.

Juts using like this  animationscript  data/scripts/screen.c the engine crashes, so i copied your code and past to my script.c that i used in my mod, so the engne didnt crash and my antity ( text ) seems to work
because its has the suntype no skip and the game stop while it was triggered and palying the animation......but nothing pops up on the screen....im trying tho adjust the position of the spawnned entity..
lets see whats hapining... ;)

"@cmd spawnscreen "entity_name" x z"  its use just x and z adjustments for postition..... there is no need  Y position?

 
Hey msmalik681 now it woks, i made all said before and just made the entity position to be spawnned....thank you for te help and this great script.... thanks!!!!
 
Back
Top Bottom