Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #define RENT_CIJENA 100
- #define DIALOG_RENT 1
- #define SCM SendClientMessage
- new VoziloZaRent[MAX_VEHICLES];
- new VoziloRentano[MAX_VEHICLES];
- new RentaVozilo[MAX_PLAYERS];
- new IdRentVozila[MAX_PLAYERS];
- main()
- {
- print("\n----------------------------------");
- print("Rent system ");
- print(" by Vuk ");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("Rent System");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- CreateRentVehicle(522,2032.8513,1330.6235,10.5474,7.4996,0,0); // rent 1
- CreateRentVehicle(411,2036.9824,1330.8070,10.4706,3.1578,0,0); // rent 2
- CreateRentVehicle(411,2041.3179,1331.1278,10.3990,5.8312,0,0); // rent 3
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- RentaVozilo[playerid] = 0;
- IdRentVozila[playerid] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(RentaVozilo[playerid] == 1)
- {
- SetVehicleToRespawn(IdRentVozila[playerid]);
- VoziloRentano[IdRentVozila[playerid]] = 0;
- RentaVozilo[playerid] = 0;
- IdRentVozila[playerid] = -1;
- }
- return 1;
- }
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////*****KOMANDE*****///////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- CMD:v(playerid,params[])
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- CreateVehicle(411,x,y,z,0,0,0,100);
- return 1;
- }
- CMD:unrentaj(playerid,params[])
- {
- if(RentaVozilo[playerid] == 1)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(GetPlayerVehicleID(playerid) == IdRentVozila[playerid])
- {
- RemovePlayerFromVehicle(playerid);
- }
- }
- SetVehicleToRespawn(IdRentVozila[playerid]);
- VoziloRentano[IdRentVozila[playerid]] = 0;
- RentaVozilo[playerid] = 0;
- IdRentVozila[playerid] = -1;
- }
- else
- {
- SCM(playerid,-1,"Ne rentas vozilo!");
- }
- return 1;
- }
- CMD:test(playerid,params[])
- {
- GivePlayerMoney(playerid,100000);
- return 1;
- }
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
- {
- new vehid = GetPlayerVehicleID(playerid);
- if(VoziloZaRent[vehid] == 1)
- {
- if(VoziloRentano[vehid] == 1 && IdRentVozila[playerid] != vehid)
- {
- RemovePlayerFromVehicle(playerid);
- }
- else if(VoziloRentano[vehid] == 0)
- {
- TogglePlayerControllable(playerid,0);
- new str[100];
- format(str,sizeof(str),"Ovo je vozilo za rent.\n Cijena renta: $%d.",RENT_CIJENA);
- ShowPlayerDialog(playerid,DIALOG_RENT,DIALOG_STYLE_MSGBOX,"Rent:",str,"Rentaj","Odustani");
- }
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_RENT)
- {
- if(!response)
- {
- TogglePlayerControllable(playerid,1);
- RemovePlayerFromVehicle(playerid);
- return 1;
- }
- if(response)
- {
- new vehid = GetPlayerVehicleID(playerid);
- if(VoziloZaRent[vehid] == 1)
- {
- if(RentaVozilo[playerid] == 0)
- {
- if(VoziloRentano[vehid] == 0)
- {
- if(GetPlayerMoney(playerid) >= RENT_CIJENA)
- {
- VoziloRentano[vehid] = 1;
- RentaVozilo[playerid] = 1;
- IdRentVozila[playerid] = vehid;
- TogglePlayerControllable(playerid,1);
- GivePlayerMoney(playerid,-RENT_CIJENA);
- }
- else
- {
- SCM(playerid,-1,"Nemas dovoljno novaca!");
- TogglePlayerControllable(playerid,1);
- RemovePlayerFromVehicle(playerid);
- }
- }
- else
- {
- SCM(playerid,-1,"Ovo vozilo je vec rentano!");
- TogglePlayerControllable(playerid,1);
- RemovePlayerFromVehicle(playerid);
- }
- }
- else
- {
- SCM(playerid,-1,"Vec rentas vozilo!");
- TogglePlayerControllable(playerid,1);
- RemovePlayerFromVehicle(playerid);
- }
- }
- else
- {
- SCM(playerid,-1,"Ovo nije rent vozilo!");
- TogglePlayerControllable(playerid,1);
- RemovePlayerFromVehicle(playerid);
- }
- }
- return 1;
- }
- return 1;
- }
- stock CreateRentVehicle(vehmod,Float:x,Float:y,Float:z,Float:rot,col1,col2)
- {
- new vehid;
- vehid = CreateVehicle(vehmod,Float:x,Float:y,Float:z,Float:rot,col1,col2,100);
- VoziloZaRent[vehid] = 1;
- VoziloRentano[vehid] = 0;
- SetVehicleNumberPlate(vehid,"RENT VOZILO");
- return vehid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement