if(!strcmp("/boost", cmdtext, true)) { new Float:x, Float:y, Float:z, Float:angle; GetVehicleZAngle(GetPlayerVehicleID(playerid),angle); x = floatcos(angle/4)*50; y = floatsin(90-(angle/4))*50; z = 0; SetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); return 1; }
if(!strcmp("/boost", cmdtext, true)) {
new Float:x, Float:y, Float:z, Float:angle;
new vehid = GetPlayerVehicleID(playerid);
GetVehicleZAngle(vehid(playerid),angle);
x = floatcos(angle/4)+50;
y = floatsin(90-(angle/4))+50;
z = 0;
SetVehicleVelocity(vehid(playerid),x,y,z);
return 1;
}
nevermind, I worked it out but it turned out to be much, MUCH more complex.
|
dcmd_setcarspeed(playerid,params[]) { new idx, tmp[256], tmp2[256], string[128], pid, Float:speed, Float:x, Float:y, Float:z, Float:xc, Float:yc, Float:zc, new Float:quat[4], Float:vectors[3] = {0.0,-1.0,0.0}; if(hAdmin[playerid] || IsPlayerAdmin(playerid)) { tmp = strtok(params,idx); tmp2 = strtok(params,idx); pid = strval(tmp); speed = strval(tmp2); if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /setcarspeed [playerid] [speed]"); if(!IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFFFFFFFF,"*** UFR Admin: Player not connected!"); if(GetPlayerState(pid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_YELLOW,"ERROR: Not driving a vehicle."); GetVehicleVelocity(GetPlayerVehicleID(pid), xc, yc, zc); speed = floatsqroot((xc * xc) + (yc * yc) + (zc * zc)) + speed; GetVehicleRotationQuat(GetPlayerVehicleID(pid), quat[0], quat[1], quat[2], quat[3]); new Float:mainindex[4][4], Float:X_X = quat[0] * quat[0], Float:X_Y = quat[0] * quat[1], Float:X_Z = quat[0] * quat[2], Float:X_W = quat[0] * quat[3], Float:Y_Y = quat[1] * quat[1], Float:Y_Z = quat[1] * quat[2], Float:Y_W = quat[1] * quat[3], Float:Z_Z = quat[2] * quat[2], Float:Z_W = quat[2] * quat[3]; mainindex[0][0] = 1-2*(Y_Y+Z_Z); mainindex[0][1]=2*(X_Y-Z_W); mainindex[0][2]=2*(X_Z+Y_W); mainindex[0][3]=0.0; mainindex[1][0]=2*(X_Y+Z_W); mainindex[1][1]=1-2*(X_X+Z_Z); mainindex[1][2] = 2*(Y_Z-X_W); mainindex[1][3]=0.0; mainindex[2][0]=2*(X_Z-Y_W); mainindex[2][1]=2*(Y_Z+X_W); mainindex[2][2]=1-2*(X_X+Y_Y); mainindex[2][3] = 0; mainindex[3][0]=0; mainindex[3][1]=0; mainindex[3][2]=0; mainindex[3][3]=1; z = vectors[2]*mainindex[0][0]+vectors[1]*mainindex[0][1]+vectors[0]*mainindex[0][2]+mainindex[0][3]; y = vectors[2]*mainindex[1][0]+vectors[1]*mainindex[1][1]+vectors[0]*mainindex[1][2]+mainindex[1][3]; x = -(vectors[2]*mainindex[2][0]+vectors[1]*mainindex[2][1]+vectors[0]*mainindex[2][2]+mainindex[2][3]); SetVehicleVelocity(GetPlayerVehicleID(pid), x * speed / 140, y * speed / 140, z * speed / 140); if(pid == playerid) { format(string, sizeof(string), "*** UFR Admin: You changed your car's speed to %fKm/h", floatround(1.61*floatsqroot(floatpower(floatabs(x * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0)) * 100.3)); } else { format(string, sizeof(string), "*** UFR Admin: Admin %s (ID: %d) changed your car's speed to %dKm/h", PlayerName(playerid), playerid, floatround(1.61*floatsqroot(floatpower(floatabs(x * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0)) * 100.3)); SendClientMessage(pid,COLOR_YELLOW,string); format(string, sizeof(string), "*** UFR Admin: You changed %s's (ID: %d) car's speed to %fKm/h", PlayerName(pid), pid, floatround(1.61*floatsqroot(floatpower(floatabs(x * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0) + floatpower(floatabs(y * speed / 140), 2.0)) * 100.3)); } SendClientMessage(playerid,COLOR_YELLOW,string); } else { SendClientMessage(playerid,COLOR_YELLOW,"You must be admin use this command."); } return 1; }