Script keeps crashing

esn23

Active member
Sorry Im rather new to scripts and my friend bloodbane set me up with this script. I believe he added the bottom part to it to make it centered.. But the script is crashing the game.. I am very sure it is something simple im missing but I have been out of the scene for so long lol i don't know what it is and i don't want to screw it up more lol.. Anywho here is the script...

Code:
void main(){
	// Custom sounds for picking itens
	// Douglas Baldan / O Ilusionista - 11/12/2016
	// Thanks Damon Caskey for the support
	
	void self = getlocalvar("self"); //get the self var
	void hit = getlocalvar("damagetaker"); // get target entity
	char Name = getentityproperty(self,"name"); // get target's name
	void power = getentityproperty(hit,"mp"); // get target's current mp
	int Screen = openborvariant("hResolution"); // Get screen width
	int VScreen = openborvariant("vResolution"); // Get screen height
	
	int SFX1 = loadsample("data/chars/misc/unlock/unlockbea.wav"); // load samples
	int SFX2 = loadsample("data/chars/misc/unlock/unlockcyc.wav");
	int SFX3 = loadsample("data/chars/misc/unlock/unlockemm.wav");
	int SFX4 = loadsample("data/chars/misc/unlock/unlocksto.wav");

	switch(Name) { // check the item name
	case "unlockbea" : // unlock beast
          playsample(SFX1, 0, 120, 120, 100, 0);
	  spawnAni("beaunlock",Screen/2,0,VScreen/2,"ANI_FOLLOW1");
          loadmodel("Beast");
	break;

	case "unlockcyc" : // unlock cyclops
	  playsample(SFX2, 0, 120, 120, 100, 0);
	  spawnAni("cycunlock",Screen/2,0,VScreen/2,"ANI_IDLE");
          loadmodel("Cyclops");
	break;

	case "unlockemm" : // unlock emma
	  playsample(SFX3, 0, 120, 120, 100, 0);
	  spawnAni("emmunlock",Screen/2,0,VScreen/2,"ANI_FOLLOW4");
          loadmodel("Emma_Frost");
	break;

	case "unlocksto" : // unlock storm
	  playsample(SFX4, 0, 120, 120, 100, 0);
	  spawnAni("stounlock",Screen/2,0,VScreen/2,"ANI_FOLLOW3");
          loadmodel("Storm");
	break;

	default : // in case of none of above
	break;
   	}
}

void spawnAni(void vName, float fX, float fY, float fZ, void Ani)
{
	//spawn relative to camera + Specific animation
	//Damon Vaughn Caskey + Douglas Baldan + Bloodbane
	//09/02/2021
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Y location adjustment.
	//fZ: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int iDirection = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

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

	if(iDirection == 0){ //Is entity facing left?                  
	  fX = Screen-fX; //Reverse X direction to match facing and screen length
	}

	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX + XPos, fZ + YPos, fY); //Set spawn location.
    	performattack(vSpawn, openborconstant(Ani));

	return vSpawn; //Return spawn.
}

Here is the error
Can't compile script 'cycunlock' data/chars/misc/unlock/cycunlock.txt
 
esn23 said:

esn23,

No worries friend, that's what we're here for. I don't see anything obvious, but I'm on my phone, so it's hard to diagnose from here.

Two things that would help a lot is to use code tags. Code tags are just like quote tags, they just preserve the exact text format of whatever you put between them. That way we can read the script and log a lot easier.

Here's an example:

Code:
Some stuff, like script code or log output.

The other thing is to post the entire log. That last message isn't the error... it's basically a heads up saying you should look at whole log. There's almost always a detailed error report or information upstream that will tell us exactly what happened. Just copy the log (and enclose it with code tags), and we'll probably know instantly what went wrong. :)

DC
 
I agree with Damon about posting the whole log.

I've tried the script myself even though I don't have required files and it works (no crash). So the item.c script you've quoted above is stable.
However, when reading this message:
Can't compile script 'cycunlock' data/chars/misc/unlock/cycunlock.txt

This message means the error is from cycunlock entity WHICH is spawned by the above script. If you want to search for the problem, it must be from cycunlock.txt not from item.c.
 
Back
Top Bottom