Help with system
#1

Hi. I using this filterscript: http://pastebin.com/D8fDVFma

And... I have some problems. When create spawns and I type /crate to watch where is it, system shows random distance. Also when I near a crate system say: You aren't near the crate!

Maybe somebody can help?
Reply
#2

Can you show your /crate command?
Reply
#3

Code:
CMD:crate(playerid, params[])// Outputs distance from crate in meters
{
    if(CrateObject != 0)
	{
		new rand = random(sizeof(g_CrateSpawns)),
        	Float: CrateDis = GetPlayerDistanceFromPoint(playerid, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2]),
        	string[64];

		format(string, sizeof(string), "* You're %.0f meters away from the Lost Crate.", CrateDis);
		SendClientMessage(playerid, COLOR_YELLOWGREEN, string);// Sending message to the player.
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "The crate hasn't been spawned yet. Check again soon.");// Sending message to the player.
	}
	return 1;
}
Reply
#4

Woops it was on pastebin, didn't see that. I'll take a look.

EDIT:
Ok, so that FS has an array of g_CrateSpawns with X Y Z coordinates. These are all the possible positions the crate can spawn at. The crate is created in CrateMessage at a random position of the array. When you use /crate you shouldn't use new rand = random(sizeof(g_CrateSpawns)); because that will chose a random position of the array. You should store the position of the crate when you create it.

Code:
//Top of script
new CrateObject;
new CrateIndex;

//Create the crate
new rand = random(sizeof(g_CrateSpawns));
CrateObject = CreateDynamicObject(CRATE_MODEL_ID, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2]-0.4, -1, -1, -1);
CrateIndex = rand;

//The /crate command
new Float: CrateDis = GetPlayerDistanceFromPoint(playerid, g_CrateSpawns[CrateIndex][0], g_CrateSpawns[CrateIndex][1], g_CrateSpawns[CrateIndex][2]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)