Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ZZZZZZZZZ ZZ ZZ
- Z ZZ ZZ ZZ
- Z ZZ ZZZZZ
- ZZZZZZZZZZZZ Z
- Z ZZ Z
- Z ZZ Z
- ZZZZZZZZZ Z
- ZZZZZZZZZZZZZ Z Z Z ZZZZZZZZZZZZZ ZZZZZZZZZZZZZ
- ZZ Z Z Z Z Z Z Z
- ZZ Z Z Z Z Z Z Z
- ZZ Z Z Z Z Z Z Z
- ZZ Z Z Z ZZZZZZZZZZZZZ Z Z
- ZZ Z Z Z Z Z Z Z
- ZZ Z Z Z Z Z Z Z
- ZZZZZZZZZZZZZ ZZZZZZZZZZZZZ ZZZZZZZZZZZZZ Z Z ZZZZZZZZZZZZZ
- -------------------------------------------------| @@@@@@@@@@ BY ZULAO @@@@@@@@@@ |---------------------------------------------------------------------------
- */
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100
- #define UPDATE_RATE 50
- #define CCKey KEY_ACTION
- new bool: cc[MAX_PLAYERS char];
- new Float: ccspeed[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- cc{playerid} = false;
- ccspeed[playerid] = 0.1;
- return 1;
- }
- CMD:cc(playerid,params[])
- {
- new Float: value;
- if(!sscanf(params,"f", value))
- {
- if(value < 0.05 || value > 0.15) return SendClientMessage(playerid,-1, "Valor da velocidade inválida! Limite de 0.05 até 0.15!");
- ccspeed[playerid] = value;
- new string[128];
- format(string,sizeof(string),"Você setou o valor da velocidade para %.2f!", ccspeed[playerid]);
- return SendClientMessage(playerid,-1, string);
- }
- if(cc{playerid})
- {
- cc{playerid} = false;
- return SendClientMessage(playerid,-1, "Você desabilitou o mode de Cruise Control!");
- }
- else
- {
- cc{playerid} = true;
- return SendClientMessage(playerid,-1, "Você ativou o mode de Cruise Control! Precione a tecla CTRL para andar com o veículo no modo Cruise Control. Use /cc [valor] para alterar a velocidade.");
- }
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(cc{playerid})
- {
- if(newkeys & CCKey) ccf(playerid);
- {
- new Float: x, Float:y, Float:z;
- GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
- }
- }
- return 1;
- }
- forward ccf(playerid);
- public ccf(playerid)
- {
- new keys, ud, lr;
- GetPlayerKeys(playerid, keys, ud, lr);
- if((keys & CCKey))
- {
- new Float: adirection[3];
- new vehid = GetPlayerVehicleID(playerid);
- new Float:Quaternion[4];
- new Float:transformationmatrix[4][4];
- GetVehicleRotationQuat(vehid, Quaternion[0], Quaternion[1], Quaternion[2], Quaternion[3]);
- new Float:xx = Quaternion[0] * Quaternion[0];
- new Float:xy = Quaternion[0] * Quaternion[1];
- new Float:xz = Quaternion[0] * Quaternion[2];
- new Float:xw = Quaternion[0] * Quaternion[3];
- new Float:yy = Quaternion[1] * Quaternion[1];
- new Float:yz = Quaternion[1] * Quaternion[2];
- new Float:yw = Quaternion[1] * Quaternion[3];
- new Float:zz = Quaternion[2] * Quaternion[2];
- new Float:zw = Quaternion[2] * Quaternion[3];
- transformationmatrix[0][0] = 1 - 2 * ( yy + zz );
- transformationmatrix[0][1] = 2 * ( xy - zw );
- transformationmatrix[0][2] = 2 * ( xz + yw );
- transformationmatrix[0][3] = 0.0;
- transformationmatrix[1][0] = 2 * ( xy + zw );
- transformationmatrix[1][1] = 1 - 2 * ( xx + zz );
- transformationmatrix[1][2] = 2 * ( yz - xw );
- transformationmatrix[1][3] = 0.0;
- transformationmatrix[2][0] = 2 * ( xz - yw );
- transformationmatrix[2][1] = 2 * ( yz + xw );
- transformationmatrix[2][2] = 1 - 2 * ( xx + yy );
- transformationmatrix[2][3] = 0;
- transformationmatrix[3][0] = 0;
- transformationmatrix[3][1] = 0;
- transformationmatrix[3][2] = 0;
- transformationmatrix[3][3] = 1;
- adirection[2] = -1 * transformationmatrix[0][1] + transformationmatrix[0][3];
- adirection[1] = -1 * transformationmatrix[1][1] + transformationmatrix[1][3];
- adirection[0] = -(-1 * transformationmatrix[2][1] + transformationmatrix[2][3]);
- SetVehicleVelocity(vehid, adirection[0]*ccspeed[playerid], adirection[1]*ccspeed[playerid], adirection[2]*ccspeed[playerid]);
- SetTimerEx("ccf", UPDATE_RATE, false, "i", playerid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment