14.12.2015, 16:26
Quote:
Код:
stock GetDayName() { new DayName[128]; switch(gday) { case 0: format(DayName, sizeof(DayName), "Sunday"); case 1: format(DayName, sizeof(DayName), "Monday"); case 2: format(DayName, sizeof(DayName), "Tuesday"); case 3: format(DayName, sizeof(DayName), "Wednesday"); case 4: format(DayName, sizeof(DayName), "Thursday"); case 5: format(DayName, sizeof(DayName), "Friday"); case 6: format(DayName, sizeof(DayName), "Saturday"); } return DayName; } Код:
stock SetPlayerToFacePlayer(playerid, targetid) { new Float:x[2],Float:y[2], Float:z[2],Float:angle; GetPlayerPos(targetid, x[0], y[0], z[0]); GetPlayerPos(playerid, x[1], y[1], z[1]); angle = (180.0 - atan2(x[1] - x[0], y[1] - y[0])); SetPlayerFacingAngle(playerid, angle + (5.0 * -1)); } Код:
stock FlipVehicle(vehicleid) { new Float:fAngle; GetVehicleZAngle(vehicleid, fAngle); SetVehicleZAngle(vehicleid, fAngle); SetVehicleVelocity(vehicleid, 0.0, 0.0, 0.0); } |
For the first one: It doesn't have the 'gday' parameter. It's string size definitely doesn't need to be that large. It doesn't need a slow switch. Declaring the names only once instead of using format is a lot better, and since it's "static const" it will only be declared once.
pawn Код:
stock GetDayName(day)
{
static const days[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
return days[day];
}
pawn Код:
stock SetPlayerToFacePlayer(playerid, targetid)
{
new Float:px, Float:py, Float:tx, Float:ty, Float:z;
GetPlayerPos(playerid, px, py, z);
GetPlayerPos(targetid, tx, ty, z);
SetPlayerFacingAngle(playerid, (180.0 - atan2(tx - px, ty - py));
//SetCameraBehindPlayer(playerid);
}
pawn Код:
new I@;
#define FlipVehicle(%0) SetVehicleZAngle((%0), (GetVehicleZAngle((%0), Float:I@), Float:I@))