How to add x, y to move object with floatsin, floatcos for current angle.
#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


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)