[Include] Fly Camera - Originally by Kalcor
#1

Fly Camera


This is an edited version of Kalcor's flymode filterscript. Those who don't know the general idea, this include let you toggle flying camera (a spectating screen which can be controlled with mouse and key combinations).

What's new?
  • Bug free code, the filterscript had one which you experince while no key conditions'
  • Custom camrea speed per player
  • Two types of fly camreas:
    Код:
    1 - Camera which can be moved with movement keys and rotated with mouse
    2 - Camera only rotated with mouse (immovable - like CCTVs)
    
    0 - Get player back from spectating state (NOTE: the player will be spawned where the last camera position was)
  • Easy to toggle using SetPlayerCamrea
Stocks
pawn Код:
SetPlayerCamera(playerid, type = 1);
Read the above section for types information.

pawn Код:
SetPlayerCameraSpeed(playerid, Float:speed);
The camera speed at which the fly mode will run.
(General speed = 50.0)

pawn Код:
Float: GetPlayerCameraSpeed(playerid);
Returns the player camera speed (floating unit).

And there is this callback which will be called everytime when the player moves his/her camera (not doesn't support rotation detection)
pawn Код:
public OnPlayerCameraUpdate(playerid, Float:oldx, Float:oldy, Float:oldz, olddir, Float:newx, Float:newy, Float:newz, newdir)
Dowload
The github repo:

https://github.com/Gammix/Fly-Camera


Where to use?
Here are few ideas that can be generated by this:
  • A CCTV system for game shops
  • Using it with PlayerSpectatePlayer (a spectate system like that of Counter strike)
  • Use type 2 when player dies (to let the player rotate camera from ground)
  • ...
Reply
#2

Another nice script from you. Keep on!
Reply
#3

"Flymode" filterscript was actually written by h02 AKA Scott.
Reply
#4

Nice idea, thanks again
Reply
#5

Amazing keep up the good work mate!
Reply
#6

Very nice Mr.Gammix, keep it up
Reply
#7

Update - 23/09/2015
  • Added new stock (get player camera's movement speed)
    pawn Код:
    Float: GetPlayerCameraSpeed(playerid);
  • Added new callback (called whenever player camera changes position
    pawn Код:
    public OnPlayerCameraUpdate(playerid, Float:oldx, Float:oldy, Float:oldz, olddir, Float:newx, Float:newy, Float:newz, newdir)
Done basically for those who want acceleration for camera and use things related to camera position updates.
Reply
#8

Good job!
Reply
#9

Good job gammix, another amazing script from you.
Reply
#10

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Update - 23/09/2015
  • Added new stock (get player camera's movement speed)
    pawn Код:
    Float: GetPlayerCameraSpeed(playerid);
  • Added new callback (called whenever player camera changes position
    pawn Код:
    public OnPlayerCameraUpdate(playerid, Float:oldx, Float:oldy, Float:oldz, olddir, Float:newx, Float:newy, Float:newz, newdir)
Done basically for those who want acceleration for camera and use things related to camera position updates.
The suggestions would still be better... D:

It's fine though, I can manage...

Your libraries are always promising.
Reply
#11

Suggestion:
SetPlayerCameraPos (hooked, if the player is in flymode set the object's position instead)

EDIT: In the old flymode we could set the object position and it would work. I just tried that with this and it locks the camera above the mansion.




Other Suggestion: Just more script-wise manipulation. I was hoping for more of something like this, but with flymode.
You could modify the SetPlayerCamera function to allow position and lookat parameters, that would be perfectly fine.

I tried doing it like this: https://github.com/Crayder/Fly-Camer...ter/flycam.inc
But that doesn't allow the camera to move.
Reply
#12

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Suggestion:
SetPlayerCameraPos (hooked, if the player is in flymode set the object's position instead)

EDIT: In the old flymode we could set the object position and it would work. I just tried that with this and it locks the camera above the mansion.




Other Suggestion: Just more script-wise manipulation. I was hoping for more of something like this, but with flymode.
You could modify the SetPlayerCamera function to allow position and lookat parameters, that would be perfectly fine.

I tried doing it like this: https://github.com/Crayder/Fly-Camer...ter/flycam.inc
But that doesn't allow the camera to move.
Actually you can use the native simultaneously after using SetPlayerCamera.

If your code doesn't work, that maybe because of OnPlayerUpdate, due to regular checks done there. Maybe this works:
pawn Код:
stock Cam_SetPlayerCameraPos(playerid, Float:x, Float:y, Float:z) {
    if (g_FlyMode[playerid][flyType] != 0) {
        new
            iFlyType = g_FlyMode[playerid][flyType]
        ;
        g_FlyMode[playerid][flyType] = 0;

        StopDynamicObject(g_FlyMode[playerid][flyObject])
        SetDynamicObjectPos(g_FlyMode[playerid][flyObject], x, y, z);
       
        g_FlyMode[playerid][flyType] = iFlyType;
       
        return true;
    }
    else {
        return SetPlayerCameraPos(playerid, x, y, z);
    }
}
#if defined _ALS_SetPlayerCameraPos
    #undef SetPlayerCameraPos
#else
    #define _ALS_SetPlayerCameraPos
#endif
#define SetPlayerCameraPos Cam_SetPlayerCameraPos
So You can perform position after the main stock:
pawn Код:
SetPlayerCamera(playerid, 1);
SetPlayerCameraPos(playerid, ...);
Similar can be made for SetPlayerCameraLookAt.
Reply
#13

Still the same problem. It takes me to the beach and I can't move or rotate the camera.

I updated the code again on my GH. Here is what I did to test it:
pawn Код:
SetPlayerCamera(playerid, 1);
    SetPlayerCameraPos(playerid, 0.0, 0.0, 20.0);
    SetPlayerCameraLookAt(playerid, 20.0, 20.0, 0.0);
Reply
#14

It looked good, but it dosent work for me.
It just put me in spectate mode like im speccing nobody, im using simple code to toggle this:

Код:
CMD:flycam(playerid, params[])
{
    if(PVar[playerid][pAdminLVL] != 69) return CANTUSECMD
    
	if(UsingFlyCam[playerid] == false)
	{
	    UsingFlyCam[playerid] = true;
	    SetPlayerCamera(playerid, 1);
	    ShowInfoForPlayer(playerid, "~g~Flycam enabled!", 3000);
	}
	else
	{
	    UsingFlyCam[playerid] = false;
	    SetPlayerCamera(playerid, 0);
	    ShowInfoForPlayer(playerid, "~r~Flycam disabled!", 3000);
 	}
 	return 1;
}
Edit: It got solved when i changed from streamer to player objects.
Reply
#15

I have the issue that the free camera flying is stuck after the distance that equals to the drawdistance of the object.

Is there any way to fix this?

Edit: After hours I have found the issue after some really good thinking what I have just written down, and it can be resolved via a single line. Will make multiple merge requests tomorrow since I'm tired right now.
Reply
#16

What exactly is improved/changed from the original one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)