OnplayerRequestClass Spin player
#1

I was wondering if anyone has made or could make a OnplayerRequestClass Spin with clickable textdraw so two pointers with clickable textdraw to spin the character using SetPlayerFacingAngle so you can see them better. I gave this a try and I am kindda embarrassed to even show the script :P
Reply
#2

here is one i did awhile back from a tutorial by Lorenc_
it using a timer todo a constant spin,
youll need to stop that and add your text draws


pawn Код:
//Credits to Lorenc_, this include is based on his tutorial on the spinning cam at class selection
//http://forum.sa-mp.com/showthread.php?goto=newpost&t=291910


/* ** Server Data ** 1439.2168,-785.2335,94.5855,140.5534*/
const // Constant values, you may change it to "new" if they're going to be modified once rotating.
    Float: spawnX       = 1439.2168,        // The SPAWN X you're willing to work from
    Float: spawnY       = -785.2335,        // The SPAWN Y you're willing to work from
    Float: spawnZ       = 94.5855,          // The SPAWN Y you're willing to work from
    Float: camRadius    = 3.5,              // The radius of the camera rotating
    Float: camSpeed     = 1.50,             // The speed of the camera moving around. MUST NOT BE NULL; IT WONT MOVE IF SO!
    Float: camHeight    = 0.1,              // The height of the camera once moving!
    Float: spawnAngle   = 140.5534,         // The spawns faceing angle
    spawnInt            = 0                 // The spawn interior
;

/* ** Player Data ** */
new
    prc_Timer                   [MAX_PLAYERS],  // The timer for the movement.
    bool: prc_Moving            [MAX_PLAYERS],  // Check if the player is moving his camera
    Float: prc_Degree           [MAX_PLAYERS]   // The degree counter to show which the player is on.
;


static gCLASSCAM_HasCB[3];      //for ALS hooks

forward MoveCamera(playerid); // We'll add this here to prevent future warnings..
public MoveCamera(playerid) // The core of the movement
{
    static // Static for the repeation :O
        Float: nX,  // The newX
        Float: nY   // the newY
    ;
    if(prc_Moving[playerid] == false) // check whether the timer is activated and the variable isn't.
    {
        KillTimer(prc_Timer[playerid]); // Killing the timer, ofc we don't want a 75 ms timer always running.
        prc_Degree[playerid] = 0; // Reseting the variable
    }
    if(prc_Degree[playerid] >= 360) prc_Degree[playerid] = 0; // If the rotation is past 360, reset to 0 (looks more neater)
    prc_Degree[playerid] += camSpeed; // For some smooth rotation, I'm using 1.25
   
    nX = spawnX + camRadius * floatcos(prc_Degree[playerid], degrees);
    nY = spawnY + camRadius * floatsin(prc_Degree[playerid], degrees);
   
    // So, we're going to get the spawn axis and add the radius in to them.
    // Then we use the trignometric functions to apply such angles to the movement
    // making it look nice.
    SetPlayerCameraPos(playerid, nX, nY, spawnZ + camHeight); // Setting the Camera position around the player
    SetPlayerCameraLookAt(playerid, spawnX, spawnY, spawnZ); // Looking at the player position from there :)
    //SetPlayerFacingAngle(playerid, prc_Degree[playerid] - 90.0); // to make it face the camera :)
    return 1;
}

//--------------OnGameModeInit Hook-------------------
public OnGameModeInit()
{
    //your OnGameModeInit pre code here

    //function hook checks

    gCLASSCAM_HasCB[0] = funcidx("CLASSCAM_OnPlayerDisconnect") != -1;
    gCLASSCAM_HasCB[1] = funcidx("CLASSCAM_OnPlayerRequestClass") != -1;
    gCLASSCAM_HasCB[2] = funcidx("CLASSCAM_OnPlayerSpawn") != -1;
    if (funcidx("CLASSCAM_OnGameModeInit") != -1)
    {
        return CallLocalFunction("CLASSCAM_OnGameModeInit", "");
    }
    //your OnGameModeInit post code here

    return 1;
}
#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit CLASSCAM_OnGameModeInit
forward CLASSCAM_OnGameModeInit();

//--------------OnPlayerDisconnect Hook-------------------

public OnPlayerDisconnect(playerid,  reason)
{
    if(prc_Moving[playerid] == true)
    {
        KillTimer(prc_Timer[playerid]); // Killing the timer, ofc we don't want a 75 ms timer always running.
        prc_Degree[playerid] = 0; // Reseting the variable
        prc_Moving[playerid] = false; // Reseting the variable
    }
    if (gCLASSCAM_HasCB[0])
    {
        return CallLocalFunction("CLASSCAM_OnPlayerDisconnect", "ii",playerid,  reason);
    }
    return 1;
}
#if defined _ALS_OnPlayerDisconnect
    #undef OnPlayerDisconnect
#else
    #define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect CLASSCAM_OnPlayerDisconnect
forward CLASSCAM_OnPlayerDisconnect(playerid,  reason);



//--------------OnPlayerRequestClass Hook-------------------

public OnPlayerRequestClass(playerid,  classid)
{
    SetPlayerPos(playerid, spawnX, spawnY, spawnZ); // Set the player at those 3 const spawn values from before.
    SetPlayerInterior(playerid,spawnInt);
    if(prc_Moving[playerid] == false) // Check whether the camera is already set.
    {
        prc_Degree[playerid] = 0; // Reseting the variable
        prc_Timer[playerid] = SetTimerEx("MoveCamera", 75, true, "d", playerid); // Setting the timer
        prc_Moving[playerid] = true; // okay, now we're going to activate the moving variable
    }

    if (gCLASSCAM_HasCB[1])
    {
        return CallLocalFunction("CLASSCAM_OnPlayerRequestClass", "ii",playerid,  classid);
    }
    return 1;
}
#if defined _ALS_OnPlayerRequestClass
    #undef OnPlayerRequestClass
#else
    #define _ALS_OnPlayerRequestClass
#endif
#define OnPlayerRequestClass CLASSCAM_OnPlayerRequestClass
forward CLASSCAM_OnPlayerRequestClass(playerid,  classid);



//--------------OnPlayerSpawn Hook-------------------

public OnPlayerSpawn(playerid)
{
   
    if(prc_Moving[playerid] == true)
    {
        KillTimer(prc_Timer[playerid]); // Killing the timer, ofc we don't want a 75 ms timer always running.
        prc_Degree[playerid] = 0; // Reseting the variable
        prc_Moving[playerid] = false; // Reseting the variable
        SetCameraBehindPlayer(playerid); // Preventing bugs from appearing.
    }

    if (gCLASSCAM_HasCB[2])
    {
        return CallLocalFunction("CLASSCAM_OnPlayerSpawn", "i",playerid);
    }
    return 1;
}
#if defined _ALS_OnPlayerSpawn
    #undef OnPlayerSpawn
#else
    #define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn CLASSCAM_OnPlayerSpawn
forward CLASSCAM_OnPlayerSpawn(playerid);
Reply
#3

thanks, that looks useful but I wanted something that spins the player with SetPlayerFacingAngle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)