24.11.2013, 17:49
Ele estб assim
pawn Код:
#include <a_samp>
#define COLOR_MESSAGE_YELLOW 0xFFDD00AA
#define COLOR_GREY 0xAFAFAFAA
new Float:PlayerCruiseSpeed[MAX_PLAYERS];
new Float:PlayerHeadingAngle[MAX_PLAYERS];
new CCKey = KEY_ACTION;
forward CruiseControl(playerid);
forward ccATIVADO(playerid);
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public ccATIVADO(playerid)
{
new vid = GetPlayerVehicleID(playerid);
if (GetVehicleSpeed(vid) == 0) return false;
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vid, x, y, z);
GetVehicleZAngle(vid, PlayerHeadingAngle[playerid]);
DistanceFlat(0, 0, x, y, PlayerCruiseSpeed[playerid]);
SetTimerEx("CruiseControl", 500, false, "d", playerid);
SendClientMessage(playerid, COLOR_GREY, "* Cruise control ativado.");
}
public OnGameModeInit()
{
print("[Cruise Control system by Mestr12]");
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/ccativar", true) == 0)
{
ccATIVADO(playerid);
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
GetVehicleSpeed(vehicleid)
{
new Float:Vx, Float:Vy, Float:Vz;
GetVehicleVelocity(vehicleid, Vx, Vy, Vz);
new Float:rtn;
rtn = floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
rtn = floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
return floatround(rtn);
}
DistanceFlat(Float:ax, Float:ay, Float:bx,Float:by, &Float:distance)
{
distance = floatsqroot(floatpower(bx-ax,2)+floatpower(by-ay,2));
return floatround(distance);
}
public CruiseControl(playerid)
{
new vid = GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vid, x, y, z);
new keys, ud, lr;
GetPlayerKeys(playerid, keys, ud, lr);
new Float:angle, Float:heading, Float:speed;
GetVehicleZAngle(vid, angle);
GetVehicleHeadingAngle(vid, heading);
DistanceFlat(0, 0, x, y, speed);
if ((keys & CCKey) || PlayerCruiseSpeed[playerid] == 0.00 ||
GetPlayerState(playerid) != PLAYER_STATE_DRIVER || (speed < 0.7 * PlayerCruiseSpeed[playerid]) ||
z > 1 ||
(floatabs(angle - heading) > 50 && floatabs(angle - heading) < 310))
{
PlayerCruiseSpeed[playerid] = 0.00;
SendClientMessage(playerid, COLOR_GREY, "*Cruse control disativado.");
return false;
}
GetVehicleZAngle(vid, PlayerHeadingAngle[playerid]);
GetXYVelocity(vid, x, y, PlayerCruiseSpeed[playerid]);
SetVehicleVelocity(vid, x, y, z);
return SetTimerEx("CruiseControl", 500, false, "d", playerid);
}
GetXYVelocity(vehicleid, &Float:x, &Float:y, Float:speed)
{
new Float:a;
x = 0.0;
y = 0.0;
GetVehicleZAngle(vehicleid, a);
x += (speed * floatsin(-a, degrees));
y += (speed * floatcos(-a, degrees));
}
GetAngleToXY(Float:X, Float:Y, Float:CurrentX, Float:CurrentY, &Float:Angle)
{
Angle = atan2(Y-CurrentY, X-CurrentX);
Angle = floatsub(Angle, 90.0);
if(Angle < 0.0) Angle = floatadd(Angle, 360.0);
}
GetVehicleHeadingAngle(vehicleid, &Float:a)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vehicleid, x, y, z);
GetAngleToXY(x, y, 0, 0, a);
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}