new FirstPerson[MAX_PLAYERS];
new FirstPersonObject[MAX_PLAYERS];
new bool:FPS[MAX_PLAYERS];
stock StartFPS(playerid) //To start the FPS mod.
{
FirstPersonObject[playerid] = CreateObject(19300, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);//You must need this, if you don't the camera will glitch.
AttachObjectToPlayer(FirstPersonObject[playerid],playerid, 0.0, 0.12, 0.7, 0.0, 0.0, 0.0);//Just Attached the object.
AttachCameraToObject(playerid, FirstPersonObject[playerid]);//Now, I have sttach my camera to that object that i have created.
FirstPerson[playerid] = 1;//New variable is now TRUE ( 1= True)
CallLocalFunction("OnPlayerHaveFirstPerson", "i", playerid);//I have called the Local Function of OnPlayerHaveFirstPerson .
return 1;
}
stock StopFPS(playerid) //As you have start the FPS, That must need deactive function too .
{
SetCameraBehindPlayer(playerid);// Just moved his camera behind the player.
DestroyObject(FirstPersonObject[playerid]);//Destroyed that Object that i have created on first.
FirstPerson[playerid] = 0;// 0= False .
CallLocalFunction("OnPlayerDoNotHaveFirstPerson", "i", playerid);//Same as before, I have just deactive that callback ( called OnPlayerDoNotHaveFirstPerson .
return 1;
}
stock Reset(playerid)
{
FirstPerson[playerid] = 0;//Just if you are bugged . Reset.
}
if(FirstPerson[playerid] == 1)
{
StopFPS[playerid];
}
CMD:fps(playerid, params[])
{
//SendClientMessageEx(playerid, COLOR_LIME, "If you think you cannot use /fps , Please /resetfps to fix it up. Then use /fps again."); //Depend on you that you will use it or not.
if(FPS[playerid] == false) // You can use FPS[playerid] == 0) 0=False.
{
FPS[playerid] = true;//Same as before, You can use 1 tho.
StartFPS(playerid);//Called that StartFPS stock to use FPS.
}
else if(FPS[playerid] == true)// Same as before, you can use 1 here.
{
FPS[playerid] = false;// You can use 0 if you don't want to false.
StopFPS(playerid);//Called Stock StopFPS
}
return 1;
}
CMD:resetfps(playerid, params[])
{
Reset(playerid);
return 1;
}
//OnPlayerDeath
if(FirstPerson[playerid] == 1)
{
StartFPS[playerid];
}
Simple, but nicely explained.
P.S: You should re-start the FPS mode when the player dies. Example is below. PHP код:
|
What is the use of OnPlayerHaveFirstPerson and OnPlayerDoNotHaveFirstPerson for?
You have explained that part but you haven't mentioned the use of these callbacks. |
Should be StartFPS to start it back again if the player had FPS on. It's kind of annoying to put back /fps when a player died to get the FPS view again.
|
Oh yeah, sorry! I got mistaken, you should add the code i've posted OnPlayerSpawn
![]() |
OnPlayerHaveFirstPerson and OnPlayerDoNotHaveFirstPerson is used because of no crash when we use fps.
There no main point of use it. Just to avoid glitch and crash, I am using it. |
You do realize that the code calls the callback and you told me that it is only placed there to prevent a crash but it has no further use? You shouldv remoe that CallLocalFunction othwisere if it has no use at all because removing it won't cause any crashes on my point of view.
|