SA-MP Forums Archive
First Person Script Tutorial/help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: First Person Script Tutorial/help (/showthread.php?tid=458473)



First Person Script Tutorial/help - NinjahZ - 16.08.2013

Does anyone know if a filterscript has been released or if a tutorial has been made for firstperson ? cause I would like to use it :/


Re: First Person Script Tutorial/help - RedFusion - 16.08.2013

My gamemode "Ripple" features first person view. It's here on the forums.


Re: First Person Script Tutorial/help - NinjahZ - 16.08.2013

Would you mind if I use it in my GM I am making?
It is going to be released here on the forums...would you be able to help me implement it into the GM aswell,cause I know nothing about your script I dont even know where the code is :P
Like could you send me a link to a pastebin of just the fp view?


Re: First Person Script Tutorial/help - RedFusion - 16.08.2013

Part of it:
pawn Код:
forward UpdateFirstPerson();
public UpdateFirstPerson()
{
    foreach(new playerid : Player)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new vehicleid, model;
            vehicleid = GetPlayerVehicleID(playerid);
            model = GetVehicleModel(vehicleid);

            switch(model)
            {
                case 432,441,464,465,501,564,569,570,590,591,601,
                606,607,608,610,611,460,476,511,512,513,520,553,
                577,592,593,548,425,417,487,488,497,563,447,469:
                {
                    SetPlayerFirstPersonMode(playerid,0);
                }
                default: SetPlayerFirstPersonMode(playerid,1);
            }
        }
        else
        {
            if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DUCK)
            {
                if(IsPlayerMoving(playerid)) SetPlayerFirstPersonMode(playerid,2);
                else SetPlayerFirstPersonMode(playerid,3);
            }
            else
            {
                if(IsPlayerMoving(playerid)) SetPlayerFirstPersonMode(playerid,4);
                else SetPlayerFirstPersonMode(playerid,5);
            }
        }
    }
    return 1;
}

stock SetPlayerFirstPersonMode(playerid,mode)
{
    if(GetTickCount() - pFirstPersonTick[playerid] < 500) mode = 0;
    else pFirstPersonTick[playerid] = 0;

    if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) return 0;
    if(pFirstPersonMode[playerid] == mode) return 0;
    pFirstPersonMode[playerid] = mode;

    if(mode == 0) // Third Person
    {
        SetCameraBehindPlayer(playerid);
        return 1;
    }

    if(!IsValidObject(pFirstPersonObj[playerid]))
        pFirstPersonObj[playerid] = CreateObject(19300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);

    switch(mode)
    {
        case 1:// First Person, In Vehicle
        {
            new vehicleid, model, seat, Float:x, Float:y, Float:z;
            vehicleid = GetPlayerVehicleID(playerid);
            model = GetVehicleModel(vehicleid);
            seat = GetPlayerVehicleSeat(playerid);

            switch(seat)
            {
                case 0,1: GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_FRONTSEAT, x, y, z);
                default: GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_REARSEAT, x, y, z);
            }
            if(IsNumberEven(seat)) AttachObjectToVehicle(pFirstPersonObj[playerid], vehicleid, -x, y, z + 0.70, 0.0, 0.0, 0.0);
            else AttachObjectToVehicle(pFirstPersonObj[playerid], vehicleid, x, y, z + 0.70, 0.0, 0.0, 0.0);
        }
        case 2:// First Person, Crouched & Moving
            AttachObjectToPlayer(pFirstPersonObj[playerid], playerid, 0.10, 0.30, 0.30, 0.0, 0.0, 0.0);
        case 3:// First Person, Crouched & Not Moving
            AttachObjectToPlayer(pFirstPersonObj[playerid], playerid, 0.10, 0.25, 0.20, 0.0, 0.0, 0.0);
        case 4:// First Person, Standing & Moving
            AttachObjectToPlayer(pFirstPersonObj[playerid], playerid, 0.0, 0.30, 0.75, 0.0, 0.0, 0.0);
        case 5:// First Person, Standing & Not Moving
            AttachObjectToPlayer(pFirstPersonObj[playerid], playerid, 0.0, 0.10, 0.80, 0.0, 0.0, 0.0);
    }

    AttachCameraToObject(playerid, pFirstPersonObj[playerid]);
    return 1;
}
https://github.com/fusez/ripple/blob.../functions.pwn


Re: First Person Script Tutorial/help - NinjahZ - 16.08.2013

***Deleted Post***


Re: First Person Script Tutorial/help - NinjahZ - 16.08.2013

Nevermind I did it,again id like to ask if I could use this for the GM I am creating,I will make credits for you.


Re: First Person Script Tutorial/help - RedFusion - 17.08.2013

Ofcourse, it's released and public and if you give credits it's even better


Re: First Person Script Tutorial/help - NinjahZ - 17.08.2013

Allright,thank you