13.02.2010, 13:58
The OnDuty query in the filterscript does not go. The cops are always flashed.
Sorry, is in the wrong board. Please move..
Sorry, is in the wrong board. Please move..
Код:
#include <a_samp> // Credits: Peter <3 && Antironix for adding Speeding Limit // Tekst: Well i didn't care what speedo meter i toke, but the other one didn't worked. // I just wanted to make the flitspaal and not the speedo meter. // Thx #pragma tabsize 0 static gTeam[MAX_PLAYERS]; //new gTeam[MAX_PLAYERS]; #define TEAM_COPS 2 new OnDuty[MAX_PLAYERS]; //---------------------------------------- new UpdateSeconds = 1; // How frequent do you want it to be updated? new maxobject = 9; //define how many "flitspalen" you have //---------------------------------------- public OnFilterScriptInit() { print("\n----------------------------------"); print("Filterscript Speeding control loaded"); print("----------------------------------\n"); SetTimer("UpdateSpeed", UpdateSeconds*1000, 1); } public OnFilterScriptExit() { print("\n----------------------------------"); print("Filterscript Speeding control un-loaded"); print("----------------------------------\n"); } forward UpdateSpeed(playerid); enum SavePlayerPosEnum { Float:LastX, Float:LastY, Float:LastZ } #define COLOR_RED 0xAA3333AA #define COLOR_YELLOW 0xFFFF00AA #define SLOTS 200 new objectcreated; new SavePlayerPos[SLOTS][SavePlayerPosEnum]; new distance1[MAX_PLAYERS]; public UpdateSpeed(playerid) { new Float:x,Float:y,Float:z; new Float:distance,value; for(new i=0; i<SLOTS; i++) { if(IsPlayerConnected(i)) { GetPlayerPos(i, x, y, z); distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2)); // Distance: meters in the last second value = floatround(distance * 3600); if(UpdateSeconds > 1) { value = floatround(value / UpdateSeconds); } distance1[i] = floatround(value/1100); SavePlayerPos[i][LastX] = x; SavePlayerPos[i][LastY] = y; SavePlayerPos[i][LastZ] = z; AddBlitzer(i, 1278, 2077.5579,1013.2529,10.8203, 20, 100); //Hier die Blitzer rein (Unsichtbare Speeding Boundries) AddBlitzer(i, 1278, 2077.5579,1013.2529,10.8203, 20, 100); AddBlitzer(i, 1278, 2078.9189,1235.0403,10.3865, 20, 100); AddBlitzer(i, 1278, 1207.4088,-929.6893,42.9278, 20, 100); AddBlitzer(i, 1278, 1452.9301,-1027.5425,23.8281, 20, 100); AddBlitzer(i, 1278, 1350.0983,-1419.0045,13.5469, 20, 100); AddBlitzer(i, 1278, 1689.8768,-1446.8567,13.5469, 20, 100); AddBlitzer(i, 1278, 1849.4011,-1396.5714,13.3906, 20, 100); } // End is-player-connected } // End for-loop } // eind UpdateSpeed function public OnPlayerRequestClass(playerid, classid) { if(classid == 0) { gTeam[playerid] = TEAM_COPS; } if(classid == 1) { gTeam[playerid] = TEAM_COPS; } return 1; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } IsPlayerInCircle(playerid,Float:x,Float:y,radius) { if(GetPlayerDistanceToPoint(playerid,Float:x,Float:y) < radius) { return 1; } return 0; } GetPlayerDistanceToPoint(playerid,Float:x,Float:y) { new Float:x1,Float:y1,Float:z1; GetPlayerPos(playerid,x1,y1,z1); new Float:tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+ floatpower(floatabs(floatsub(y,y1)),2)); return floatround(tmpdis); } stock AddBlitzer(playerid, modelid, Float:xx, Float:yy, Float:zz, radius, speed) { new fine[MAX_PLAYERS]; new str[256]; if(objectcreated!=maxobject) { CreateObject(modelid, xx, yy, zz, 0.0, 0.0, 10); objectcreated++; } if((distance1[playerid])>speed) { if(IsPlayerInCircle(playerid, xx, yy, radius) && GetPlayerState(playerid)== PLAYER_STATE_DRIVER) { if(OnDuty[playerid] == 1 && gTeam[playerid] == TEAM_COPS) { SendClientMessage(playerid, COLOR_RED, "You were not flashed, because you're a cop on duty!"); return 1; } fine[playerid]=((distance1[playerid]*17/10)-speed); GivePlayerMoney(playerid, -fine[playerid]); format(str,sizeof(str), "You're faster than %d(%d) and had to pay $%d",speed, distance1[playerid] ,fine[playerid]); SendClientMessage(playerid, COLOR_YELLOW, str); } } return 1; }