09.03.2014, 15:15
My filterscript buy vehicle, but i do'nt know save/load vehicle when disconnect and login.
I using dini. Please help me
I using dini. Please help me
Код:
#include <a_samp> #include <zcmd> #include "../include/Car.inc" #pragma unused aBakai #pragma unused aVehicleNames #pragma unused aEda #define RED 0xE60000FF #define WHITE 0xFFFFFFFF #define GREEN 0x21DD00FF new VehicleSelected[MAX_PLAYERS]; new Float:ShopSpawn[][] = { {-1936.2046,274.0648,41.1902,179.3101}, {-1928.6871,273.9744,41.2011,179.3109}, {-1936.2046,274.0648,41.1902,179.3101}, {-1928.6871,273.9744,41.2011,179.3109}, {-1936.2046,274.0648,41.1902,179.3101}, {-1928.6871,273.9744,41.2011,179.3109} }; enum ShopVehiclesData { VehicleModel, VehicleID, Price, Float: Pos_X, Float: Pos_Y, Float: Pos_Z, Float: Pos_A }; new ShopVehicles[14][ShopVehiclesData] = { //{Vehicle Model, -1, Price, PosX, PosY, PosZ, PosA} {411, -1, 50000, -1958.4098, 282.2295, 35.1958, 53.4286}, {559, -1, 23000, -1957.5858, 302.2093, 35.1961, 120.0996}, {560, -1, 20000, -1945.6851, 260.9796, 35.1958, 59.7401}, {506, -1, 25000, -1945.3628, 264.5180, 35.2029, 59.7403}, {445, -1, 9000, -1945.2078, 271.6658, 35.2010, 70.8415}, {436, -1, 2000, -1960.7921, 256.6944, 35.1997, 328.1125}, {439, -1, 5000, -1953.8215, 256.4964, 35.1984, 330.6804}, {477, -1, 30000, -1946.8446, 272.6502, 40.8047, 120.5285}, {451, -1, 45000, -1946.6680, 264.3454, 40.7554, 70.9541}, {429, -1, 20250, -1946.7561, 257.4010, 40.7267, 46.6415}, {565, -1, 10000, -1953.5293, 256.6174, 40.6719, 359.3146}, {496, -1, 8500, -1954.8274, 304.7871, 40.7627, 133.0103}, {475, -1, 9600, -1952.9268, 298.2675, 40.8687, 134.6961}, {602, -1, 12000, -1952.6975, 291.7539, 40.8538, 128.8214} }; enum item { pcar } new pInfo[MAX_PLAYERS][item]; enum vitem { gas, bool:locked, bool:parduodama, lastuser, Masinos_Modelis, Float:lastpos[4], owner_name[MAX_PLAYER_NAME] } new vehicleDB[MAX_VEHICLES][vitem]; main() { print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); print("xxxCar Shop System By MaxSaint xx"); print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); } public OnGameModeInit() { print("\n----------------------------------"); print(" "); print("----------------------------------\n"); AddPlayerClass(250,-1950.5710,149.0612,26.2813,90.2741,0,0,0,0,0,0); for(new i = 0; i < sizeof(ShopVehicles); i ++) { ShopVehicles[i][VehicleID] = CreateVehicle(ShopVehicles[i][VehicleModel], ShopVehicles[i][Pos_X], ShopVehicles[i][Pos_Y], ShopVehicles[i][Pos_Z], ShopVehicles[i][Pos_A], -1, -1, -1); vehicleDB[ShopVehicles[i][VehicleID]][parduodama] = true; new String[128]; format(String, sizeof(String), "{99ff00}Vehicle :{FFFFFF} %s\n{99ff00}Price :{FFFFFF} %i$\n{99ff00}Sell price:{FFFFFF} %i$", aVehicleNames[GetVehicleModel(ShopVehicles[i][VehicleID]) - 400], ShopVehicles[i][Price], ShopVehicles[i][Price]/2); Attach3DTextLabelToVehicle(Create3DTextLabel(String, -1, 0.0, 0.0, 0.0, 10.0, 0), ShopVehicles[i][VehicleID], 0.0, 0.0, 1.0); } return 1; } public OnFilterScriptExit() { return 1; } CMD:masinukas(playerid, params[]) { if(pInfo[playerid][pcar] == -1) { SendClientMessage(playerid,RED,"You don't have a car."); return 1; } new msg[128],Float:coo[6]; GetVehiclePos(pInfo[playerid][pcar],coo[0],coo[1],coo[2]); GetPlayerPos(playerid,coo[3],coo[4],coo[5]); new Float:atstumas = ((floatabs(coo[0]-coo[3])+floatabs(coo[1]-coo[4])+floatabs(coo[2]-coo[5]))/3)/100; SetPlayerCheckpoint(playerid,coo[0],coo[1],coo[2],2); new salis1[10],salis2[10]; if(coo[0]-coo[3]>0) salis1="rytus"; else salis1="vakarus"; if(coo[1]-coo[4]>0) salis2="рiaurлs"; else salis2="pietш"; format(msg,sizeof(msg),"Your car are where are checkpoint.",atstumas,salis2,salis1); SendClientMessage(playerid,WHITE,msg); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { new vehicleid = GetPlayerVehicleID(playerid); if(vehicleDB[vehicleid][parduodama]) { TogglePlayerControllable(playerid, false); new String[512]; format(String, sizeof(String), "{99ff00}Vehicle Model: {FFFFFF}%s\n{99ff00}Price: {FFFFFF}%i$\n\n{99ff00}Consider and select whether you want to buy.", aVehicleNames[GetVehicleModel(vehicleid) - 400], ShopVehicles[IsShopVehicle(vehicleid)][Price]); ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "Automobilio pirkimas", String, "Pirkti", "Iрeiti"); VehicleSelected[playerid] = IsShopVehicle(vehicleid); } return 1; } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 100) { if(response) { new vehicleid = VehicleSelected[playerid]; new iRandom = random(sizeof(ShopSpawn)); new vehicleids = CreateVehicle(ShopVehicles[vehicleid][VehicleModel], ShopSpawn[iRandom][0], ShopSpawn[iRandom][1], ShopSpawn[iRandom][2], ShopSpawn[iRandom][3], -1, -1, -1); pInfo[playerid][pcar] = vehicleids; vehicleDB[vehicleids][locked] = true; vehicleDB[vehicleids][gas] = 40; GetPlayerName(playerid, vehicleDB[vehicleids][owner_name], MAX_PLAYER_NAME); SendClientMessage(playerid, GREEN, "{EE5555}[SERVERIS]{FFFFFF} Your Car Was created , tipe /car"); GivePlayerMoney(playerid, -ShopVehicles[vehicleid][Price]); RemovePlayerFromVehicle(playerid); TogglePlayerControllable(playerid, true); } else { RemovePlayerFromVehicle(playerid); TogglePlayerControllable(playerid, true); } return 1; } return 1; } stock IsShopVehicle(vehicleid) { for(new i = 0; i < sizeof(ShopVehicles); i ++) { if(ShopVehicles[i][VehicleID] == vehicleid) { return i; } } return -1; }