10.08.2009, 20:54
What is this ?
It's a simple game mode addon which makes your camera spin around the player in the skin selection screenInstallation
For this script to work correctly, delete the SetPlayerPos, SetPlayerFacingAngle, SetCameraPos, SetCameraFacingAngle, ApplyAnimation and PlayerPlaySound lines from your OnPlayerRequestSpawn and correctly copy the code into your modeOn top of script
pawn Код:
//where the player will spawn
#define player_x -250.9738
#define player_y 2585.6497
#define player_z 63.5703
#define player_angle 210.3500
//PLAYER CAMERA, THE ONE YOU CREATE SO YOU CAN SEE THE PLAYER
//note: for a better effect, let the camera be a few meters away from the player
#define camera_x -248.9410
#define camera_y 2581.5327
#define camera_z 64.9334
//ATTENTION; THESE ARE MILISECONDS
//untested, but it should work in theory. The smaller the value, the faster the camera.
#define moving_speed 50
//declaring stuff
//IMPORTANT: FOR THE CODE TO WORK, YOU MUST DEFINE THE ENUM BEFORE PlayerInfo
//just copy it like It's written here
enum pInfo
{
bool:SpawnDance,
Float:SpawnAngle,
SpawnTimer
};
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, player_x,player_y,player_z);
SetPlayerFacingAngle(playerid, player_angle);
SetPlayerCameraPos(playerid, camera_x,camera_y,camera_z);
SetPlayerCameraLookAt(playerid, player_x,player_y,player_z);
ApplyAnimation(playerid,"DANCING","DNCE_M_B",4.0,1,0,0,0,-1); //smooth dancing. It's most fitting to the music
PlayerPlaySound(playerid, 1097,-119.9460,23.1096,12.2238); //music, duh
//making sure the timer gets executed only once, so the camera doesn't go to fast
if (PlayerInfo[playerid][SpawnDance]) PlayerInfo[playerid][SpawnTimer] = SetTimerEx("MoveCamera", moving_speed, true, "i", playerid);
PlayerInfo[playerid][SpawnDance] = false; //preventing the timer to execute again
return 1;
}
pawn Код:
//something I found in vactions.pwn
PreloadAnimLib(playerid, animlib[]) ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
public OnPlayerConnect(playerid)
{ //loading the animation libraries
PreloadAnimLib(playerid,"BOMBER");
PreloadAnimLib(playerid,"RAPPING");
PreloadAnimLib(playerid,"SHOP");
PreloadAnimLib(playerid,"BEACH");
PreloadAnimLib(playerid,"SMOKING");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"ON_LOOKERS");
PreloadAnimLib(playerid,"DEALER");
PreloadAnimLib(playerid,"CRACK");
PreloadAnimLib(playerid,"CARRY");
PreloadAnimLib(playerid,"COP_AMBIENT");
PreloadAnimLib(playerid,"PARK");
PreloadAnimLib(playerid,"INT_HOUSE");
PreloadAnimLib(playerid,"FOOD");
PreloadAnimLib(playerid,"PED");
//so the timer can be executed again
PlayerInfo[playerid][SpawnDance] = true;
ApplyAnimation(playerid,"DANCING","DNCE_M_B",4.0,1,0,0,0,-1); //preventing a bug for the animation not being applied the first time OnPlayerRequestClass is called
return 1;
}
pawn Код:
public OnPlayerSpawn(playerid)
{
PlayerInfo[playerid][SpawnAngle] = 0.0; //so when you leave and another player comes, the camera will start from start
PlayerInfo[playerid][SpawnDance] = true; //to not execute to much timers
KillTimer( PlayerInfo[playerid][SpawnTimer] ); //to kill it, since its useless now
PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0); // (blank sound) to shut the music up
SetCameraBehindPlayer(playerid); //to prevent some bugs
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
KillTimer( PlayerInfo[playerid][SpawnTimer] );
return 1;
}
pawn Код:
//The business part of the code
forward MoveCamera(playerid);
public MoveCamera(playerid)
{
//this is called trigonometry. It makes the camera spin
//you can experiment with this line. Just change the values 2, 10 and 3 to make different effects
SetPlayerCameraPos(playerid, player_x - 2 * floatsin(-PlayerInfo[playerid][SpawnAngle], degrees), player_y - 10 * floatcos(-PlayerInfo[playerid][SpawnAngle], degrees), player_z + 3);
SetPlayerCameraLookAt(playerid, player_x, player_y, player_z + 0.5);
//changing the angle a little
PlayerInfo[playerid][SpawnAngle] += 0.5;
if (PlayerInfo[playerid][SpawnAngle] >= 360.0)
PlayerInfo[playerid][SpawnAngle] = 0.0;
}
The result
If you done everything correctly, it should look something like this on your server
SAMP Player Request Class vid
I have custom skins installed
This is my first release. It's hard to be original with all the other scripts beeing so good
Please leave comments
SAMP Player Request Class vid
I have custom skins installed
This is my first release. It's hard to be original with all the other scripts beeing so good
Please leave comments