enum pCar { Near }; new CB[MAX_PLAYERS][pCar]; #define MAX_V 2000 new VInfo[MAX_V]; main() { print("\n----------------------------------"); print(" Vehicle System"); print("----------------------------------\n"); } public OnGameModeInit() { print("GameModeInit()"); SetGameModeText("Vehicle Ownership"); SetTimer("ConstFunctions",1000,1); AddStaticVehicle(415,2040.1259,1336.6646,10.4430,180.0130,25,1); AddPlayerClass(2, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { new string[256]; //printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate); for (new i = 0; i < MAX_PLAYERS; i++) { if(GetPlayerState(i) == 2) { if(CB[i][Near] == 1) { format(string,sizeof(string),"* This Vehicle is for sale for %d,/cBuy to buy *"); SendClientMessage(i,COLOR_GREY,string); } } } return 1; } public ConstFunctions() { for (new i = 0; i < MAX_PLAYERS; i++) { if (IsPlayerConnected(i)) { VehicleUpdate(); } } return 1; } stock AddVehicleForSale(vehicleid, Float:x, Float:y, Float:z, name[], price, bool:forsale, saleid) { if(!fexist(vehiclefile(saleid))) { dini_Create(vehiclefile(saleid)); dini_IntSet(vehiclefile(saleid), "vehicle", vehicleid); dini_Set(vehiclefile(saleid), "name", name); dini_IntSet(vehiclefile(saleid), "price", price); dini_FloatSet(vehiclefile(saleid), "x", x); dini_FloatSet(vehiclefile(saleid), "y", y); dini_FloatSet(vehiclefile(saleid), "z", z); if(forsale) { dini_IntSet(vehiclefile(saleid), "forsale", 1); } else { dini_IntSet(vehiclefile(saleid), "forsale", 0); } new Float:xp, Float:yp, Float:zp; for (new i = 0; i < MAX_PLAYERS; i++) { GetPlayerPos(i, xp, yp, zp); if(GetDistanceBetweenTwoPoints(x,y, xp,yp) < 20) { CB[i][Near] = 1; } if(GetDistanceBetweenTwoPoints(x,y,xp,yp) > 20) { CB[i][Near] = 0; } VInfo[saleid] = 1; } } return 1; } stock VehicleUpdate() { AddVehicleForSale(1, 2040.1259,1336.6646,10.4430, "cheetah", 20000, true, 1); return 1; } stock vehiclefile(sale) { new string[256]; format(string, sizeof(string), "%d.vehicle", sale); return string; } stock GetDistanceBetweenTwoPoints(Float:x,Float:y, Float:x1,Float:y1) { new Float:tmpdis; tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)); return floatround(tmpdis); }