How to add x, y to move object with floatsin, floatcos for current angle.
#1

Код:
CMD:createboard(playerid, params[]) {

    new Float:px, Float:py, Float:pz, Float:pa;
    GetPlayerPos(playerid, px, py, pz);
    GetPlayerFacingAngle(playerid, pa);

    GetXYInFrontOfPlayer(playerid, px, py, 2.0);
    pz -= 1.0;
    pa += 180;
    
    CreateDynamicObject(3077, px, py, pz, 0.0000, 0.0000, pa); // Board Object

    // Calulate X, Y for Text
    pa += 90.0;    
    px = px + (2.0 * floatsin(pa, degrees));
    py = py - (2.0 * floatcos(pa, degrees));

    pz -= 1.3;

    new obj = CreateDynamicObject(19482, px, py, pz + 2.6653, 0.0000, 0.0000, pa);
    SetDynamicObjectMaterialText(obj, 0, "TOP 3 Players", OBJECT_MATERIAL_SIZE_256x256, "Arial", 16, 1, 0xFFFFFFFF, 0, 0);

    obj = CreateDynamicObject(19482, px, py, pz + 2.0553, 0.0000, 0.0000, pa);
    SetDynamicObjectMaterialText(obj, 0, "1. Player 1", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

    obj = CreateDynamicObject(19482, px, py, pz + 1.6353, 0.0000, 0.0000, pa);
    SetDynamicObjectMaterialText(obj, 0, "2. Player 2", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

    obj = CreateDynamicObject(19482, px, py, pz + 1.2153, 0.0000, 0.0000, pa);
    SetDynamicObjectMaterialText(obj, 0, "3. Player 3", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

    return 1;
}
result: It's work every angle




I want to move them into board.

How I can do it ?
Reply
#2

You can use one material text object and use \n.
Reply
#3

It can't control space between lines and text size each lines.
Reply
#4

Check out this.

https://github.com/Pottus/Texture-St.../texviewer.pwn

Line 1030, 1031

Just tweak your offsets.
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Check out this.

https://github.com/Pottus/Texture-St.../texviewer.pwn

Line 1030, 1031

Just tweak your offsets.
Thanks, but It doesn't help anything. I've already done it in my code see above.
Reply
#6

I see that but your offsets are off you need to align text to board or board to text or both.
Reply
#7

I would like this!! And work every player facing.
Reply
#8

I just told you! Figure out your offsets it's so simple...

1'st Align board to where you want it!
2'nd Align text to board!

It's so damn easy should be completed within 10 trial and error tests.
Reply
#9

Код:
CMD:createboard(playerid, params[]) {

    new Float:cbx, Float:cby;
	if (sscanf(params, "ff", cbx, cby)) {
        SendClientMessage(playerid, COLOR_GRAD1,    "USING: /createboard [x] [y]");
	    return 1;
	}
    
    new Float:px, Float:py, Float:pz, Float:pa;
    GetPlayerPos(playerid, px, py, pz);
    GetPlayerFacingAngle(playerid, pa);

    GetXYInFrontOfPlayer(playerid, px, py, 2.0);
    pz -= 1.0;
    pa += 180;
    
    CreateDynamicObject(3077, px, py, pz, 0.0000, 0.0000, pa);

    px += cbx;
    py += cby;

    pa += 90.0;    
    px = px + (2.0 * floatsin(pa, degrees));
    py = py - (2.0 * floatcos(pa, degrees));

    pz -= 1.3;

 	new obj = CreateDynamicObject(19482, px, py, pz + 2.6653, 0.0000, 0.0000, pa);
    SetDynamicObjectMaterialText(obj, 0, "TOP 3 Players", OBJECT_MATERIAL_SIZE_256x256, "Arial", 16, 1, 0xFFFFFFFF, 0, 0);

	obj = CreateDynamicObject(19482, px, py, pz + 2.0553, 0.0000, 0.0000, pa);
	SetDynamicObjectMaterialText(obj, 0, "1. Player 1", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

	obj = CreateDynamicObject(19482, px, py, pz + 1.6353, 0.0000, 0.0000, pa);
	SetDynamicObjectMaterialText(obj, 0, "2. Player 2", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

	obj = CreateDynamicObject(19482, px, py, pz + 1.2153, 0.0000, 0.0000, pa);
	SetDynamicObjectMaterialText(obj, 0, "3. Player 3", OBJECT_MATERIAL_SIZE_256x256, "Arial", 12, 1, 0xFFFFFFFF, 0, 0);

    return 1;
}

GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
	// Created by ******

	new Float:a;

	GetPlayerPos(playerid, x, y, a);

	if (GetPlayerVehicleID(playerid)) {
	    GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	}
	else GetPlayerFacingAngle(playerid, a);

	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
}
Sorry, I can't do this. I try it all day
Reply
#10

Look at the comments!

Код:
	// Calculate position to left of player
	x = (x + 1.75 * floatsin(-fa + -90,degrees));
	y = (y + 1.75 * floatcos(-fa + -90,degrees));

	// Calculate create offset
	if(FlyMode[playerid])
	{
		x = (x + 4.0 * floatsin(-fa,degrees));
		y = (y + 4.0 * floatcos(-fa,degrees));
	}
	else
	{
		x = (x + 2.0 * floatsin(-fa,degrees));
		y = (y + 2.0 * floatcos(-fa,degrees));
	}
1.) Calculate the position of the board first
2.) Calculate offsets for objects that correlates to this postion

I only have one object here, you have multiple so you need to do something like this.

Код:
startx= (startx+ 1.75 * floatsin(-fa + -90,degrees));
starty= (starty+ 1.75 * floatcos(-fa + -90,degrees));

// Calculate offsets for first object
x = (startx + 4.0 * floatsin(-fa,degrees));
y = (starty+ 4.0 * floatcos(-fa,degrees));
Createobject()....

// Calculate offsets for second object
x = (startx + 3.0 * floatsin(-fa,degrees));
y = (starty+ 3.0 * floatcos(-fa,degrees));
Createobject()....

// Calculate offsets for third object
x = (startx + 2.0 * floatsin(-fa,degrees));
y = (starty+ 2.0 * floatcos(-fa,degrees));
Createobject()....
One more thing, check this out. https://pastebin.com/rnnUUCy5

You could also just attach the text objects to the board.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)