Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- /***** Includes, Variables, Defines *****/
- #include <a_samp>
- #include <zcmd>
- #include <foreach>
- enum jcInfo
- {
- jvID,
- Owned,
- Locked
- };
- enum jpInfo
- {
- jpID,
- InJourney
- };
- new vJInfo[MAX_VEHICLES][jcInfo];
- new pJInfo[MAX_PLAYERS][jpInfo];
- new
- Float:ExitX[ MAX_PLAYERS ],
- Float:ExitY[ MAX_PLAYERS ],
- Float:ExitZ[ MAX_PLAYERS ]
- ;
- new TimesEntered[ MAX_PLAYERS ];
- #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define COLOR_NOTES 0x2894FFFF
- #define COLOR_NOTES2 0xFF0000AA
- #define DIALOG_JOURNEY_EDIT 1336
- #define DIALOG_JOURNEY_WELCOME 1337
- #define DIALOG_JOURNEY_BUY 1338
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Enterable Journey initialized. . . ");
- print("--------------------------------------\n");
- CreateObject(19354, -363.32071, -1495.16931, 515.54346, 0.00000, 90.00000, 0.00000);
- CreateObject(19354, -363.32071, -1491.96143, 515.54352, 0.00000, 90.00000, 0.00000);
- CreateObject(19354, -359.88071, -1495.16931, 515.54352, 0.00000, 90.00000, 0.18000);
- CreateObject(19354, -359.88071, -1491.96143, 515.54352, 0.00000, 90.00000, 0.18000);
- CreateObject(19354, -359.88071, -1498.37695, 515.54352, 0.00000, 90.00000, 0.18000);
- CreateObject(19354, -363.30127, -1498.37732, 515.54352, 0.00000, 90.00000, 0.18000);
- CreateObject(19353, -364.97937, -1491.95923, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -364.97940, -1495.15576, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -364.97940, -1498.34802, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -363.28708, -1499.85925, 517.22638, 0.00000, 0.00000, 90.00000);
- CreateObject(19353, -360.08200, -1499.85925, 517.22638, 0.00000, 0.00000, 90.00000);
- CreateObject(19353, -358.38437, -1498.34290, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -358.38440, -1495.13867, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -358.38440, -1491.93530, 517.22638, 0.00000, 0.00000, 0.00000);
- CreateObject(19353, -360.05481, -1490.42883, 517.22638, 0.00000, 0.00000, 90.00000);
- CreateObject(19353, -363.26331, -1490.42883, 517.22638, 0.00000, 0.00000, 89.52000);
- CreateObject(19353, -366.43570, -1490.42883, 517.22638, 0.00000, 0.00000, 89.52000);
- CreateObject(19357, -363.18289, -1498.18420, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(19357, -359.69479, -1498.18359, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(19357, -363.18500, -1494.99048, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(19357, -359.68829, -1494.99622, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(19357, -359.68549, -1491.79407, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(19357, -363.19281, -1491.77710, 518.98297, 0.00000, 90.00000, 0.00000);
- CreateObject(2844, -360.21317, -1499.40344, 515.62482, 0.00000, 0.00000, 0.00000);
- CreateObject(2846, -359.57269, -1498.80835, 515.61792, 0.00000, 0.00000, 0.00000);
- CreateObject(2372, -358.61765, -1499.28564, 515.59485, 0.00000, 0.00000, 0.00000);
- CreateObject(2394, -358.81400, -1498.70361, 516.30261, 0.00000, 0.00000, 90.00000);
- CreateObject(1742, -364.92191, -1498.74048, 515.61078, 0.00000, 0.00000, 90.00000);
- CreateObject(1755, -360.01999, -1492.61450, 515.55048, 0.00000, 0.00000, -40.00000);
- CreateObject(1756, -358.96365, -1494.05823, 515.64764, 0.00000, 0.00000, -90.00000);
- CreateObject(1823, -360.20941, -1496.04004, 515.59833, 0.00000, 0.00000, 90.00000);
- CreateObject(2298, -361.81750, -1495.81787, 515.74573, 0.00000, 0.00000, 180.00000);
- CreateObject(2296, -364.50320, -1495.87695, 515.63037, 0.00000, 0.00000, 90.00000);
- CreateObject(1823, -360.20764, -1494.87805, 515.59833, 0.00000, 0.00000, 90.00000);
- CreateObject(1742, -364.92181, -1497.32202, 515.61078, 0.00000, 0.00000, 90.00000);
- CreateObject(2204, -364.35019, -1490.57275, 515.62958, 0.00000, 0.00000, 0.00000);
- CreateObject(1208, -361.54620, -1490.82910, 515.63062, 0.00000, 0.00000, 180.00000);
- CreateObject(2524, -361.43451, -1491.05200, 515.60944, 0.00000, 0.00000, 0.00000);
- return 1;
- }
- public OnFilterScriptExit()
- {
- foreach(Player, i)
- {
- ResetPlayerInfo(i);
- }
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Version 1.2 of Enterable Journey is ready.");
- print("----------------------------------\n");
- }
- #endif
- public OnPlayerConnect(playerid)
- {
- ResetPlayerInfo(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- ResetPlayerInfo(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- ResetPlayerInfo(playerid);
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- if(GetVehicleModel(vehicleid) == 508)
- {
- ResetVehicleInfo(vehicleid);
- }
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- if(GetVehicleModel(vehicleid) == 508)
- {
- ResetVehicleInfo(vehicleid);
- }
- return 1;
- }
- CMD:journeysettings(playerid, params[]) {
- if(pJInfo[playerid][InJourney])
- {
- //new jID = pJInfo[playerid][jpID];
- for(new i=1;i<MAX_VEHICLES;i++)
- {
- if(GetVehicleModel(i) == 508)
- {
- new Float:fDistance = GetVehicleDistanceFromPoint(i, ExitX[playerid], ExitY[playerid], ExitZ[playerid]);
- if(fDistance < 10)
- {
- if(pJInfo[playerid][jpID] == vJInfo[i][jvID])
- {
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_EDIT, DIALOG_STYLE_LIST, "{FFFFFF}Edit your {00C0FF}Journey", "{FFFFFF}Lock the {00C0FF}Journey\n{FFFFFF}Unlock the {00C0FF}Journey\n{FFFFFF}Disown the {00C0FF}Journey", "Select", "Close");
- return 1;
- }
- else SendClientMessage(playerid, COLOR_NOTES2, "[NOTE] You're not the owner of this 'Journey'!");
- }
- }
- }
- }
- else SendClientMessage(playerid, COLOR_NOTES, "[INFO] You need to be in the 'Journey' to edit it.");
- return 1;
- }
- CMD:editjourney(playerid, params[])
- return cmd_journeysettings(playerid, params);
- /*
- This was used for testing!
- CMD:myjourney(playerid, params[]) {
- new string[50];
- new vID = pJInfo[playerid][jpID];
- format(string, sizeof(string), "jpID: %d .... jvID: %d", pJInfo[playerid][jpID], vJInfo[vID][jvID]);
- SendClientMessage(playerid, COLOR_NOTES, string);
- return 1;
- }*/
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- new vID = GetPlayerVehicleID(playerid);
- if(GetVehicleModel(vID) == 508)
- {
- if(!vJInfo[vID][Locked])
- {
- TimesEntered[playerid]++;
- if(!vJInfo[vID][Owned]) ShowPlayerDialog(playerid, DIALOG_JOURNEY_BUY, DIALOG_STYLE_LIST, "{FFFFFF}Buy the {00C0FF}Journey", "{00C0FF}* {FFFFFF}Buy the {00C0FF}Journey", "Select", "Cancel");
- else
- {
- if(pJInfo[playerid][jpID] != vJInfo[vID][jvID] && TimesEntered[playerid] < 2)
- {
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_WELCOME, DIALOG_STYLE_MSGBOX, "{FFFFFF}Introduction to the {00C0FF}Journey", "{FFFFFF}The {00C0FF}Journey {FFFFFF}is your Mobile/Temporary house.\nYou can own it by getting the keys of it.", "Close", "");
- }
- else if(pJInfo[playerid][jpID] != vJInfo[vID][jvID])
- {
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_EDIT, DIALOG_STYLE_LIST, "{FFFFFF}Edit your {00C0FF}Journey", "{FFFFFF}Lock the {00C0FF}Journey\n{FFFFFF}Unlock the {00C0FF}Journey\n{FFFFFF}Disown the {00C0FF}Journey", "Select", "Close");
- }
- }
- }
- else RemovePlayerFromVehicle(playerid);
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_YES))
- {
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X,Y,Z);
- for(new i=1;i<MAX_VEHICLES;i++)
- {
- if(GetVehicleModel(i) == 508)
- {
- new Float:fDistance = GetVehicleDistanceFromPoint(i, X, Y, Z);
- if(fDistance < 3.0)
- {
- if(!vJInfo[i][Locked])
- {
- ExitX[playerid] = X, ExitY[playerid] = Y, ExitZ[playerid] = Z;
- TogglePlayerControllable(playerid, 0), SetTimerEx("Unfreeze", 2000, false, "i", playerid);
- SetPlayerPos(playerid, -360.6434,-1499.0181,516.6295), SetPlayerVirtualWorld(playerid, 1);
- SetCameraBehindPlayer(playerid);
- TimesEntered[playerid]++;
- pJInfo[playerid][InJourney] = 1;
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] You've entered the 'Journey', to leave it, press 'N'.");
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] To edit the Journey, type '/journeysettings', or '/editjourney'");
- if(!vJInfo[i][Owned]) ShowPlayerDialog(playerid, DIALOG_JOURNEY_BUY, DIALOG_STYLE_LIST, "{FFFFFF}Buy the {00C0FF}Journey", "{00C0FF}* {FFFFFF}Buy the {00C0FF}Journey", "Select", "Cancel");
- else
- {
- if(pJInfo[playerid][jpID] != vJInfo[i][jvID] && TimesEntered[playerid] < 2)
- {
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_WELCOME, DIALOG_STYLE_MSGBOX, "{FFFFFF}Introduction to the {00C0FF}Journey", "{FFFFFF}The {00C0FF}Journey {FFFFFF}is your Mobile/Temporary house.\nYou can own it by getting the keys of it.", "Close", "");
- }
- else if(pJInfo[playerid][jpID] != vJInfo[i][jvID])
- {
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_EDIT, DIALOG_STYLE_LIST, "{FFFFFF}Edit your {00C0FF}Journey", "{FFFFFF}Lock the {00C0FF}Journey\n{FFFFFF}Unlock the {00C0FF}Journey\n{FFFFFF}Disown the {00C0FF}Journey", "Select", "Close");
- }
- }
- }
- else
- {
- if(pJInfo[playerid][jpID] != vJInfo[i][jvID])
- {
- SendClientMessage(playerid, COLOR_NOTES2, "[INFO] This 'Journey' is locked.");
- }
- else
- {
- ExitX[playerid] = X, ExitY[playerid] = Y, ExitZ[playerid] = Z;
- TogglePlayerControllable(playerid, 0), SetTimerEx("Unfreeze", 2000, false, "i", playerid);
- SetPlayerPos(playerid, -360.6434,-1499.0181,516.6295), SetPlayerVirtualWorld(playerid, 1);
- SetCameraBehindPlayer(playerid);
- TimesEntered[playerid]++;
- pJInfo[playerid][InJourney] = 1;
- }
- }
- return 1;
- }
- }
- }
- }
- else if(PRESSED(KEY_NO))
- {
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X,Y,Z);
- if(IsPlayerInRangeOfPoint(playerid, 8.0, -360.6434,-1499.0181,516.6295))
- {
- SetPlayerPos(playerid, ExitX[playerid], ExitY[playerid], ExitZ[playerid]), SetPlayerVirtualWorld(playerid, 0);
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] You've left the 'Journey'");
- pJInfo[playerid][InJourney] = 0;
- return 1;
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_JOURNEY_BUY:
- {
- if(response)
- {
- new Float:X, Float:Y, Float:Z, count = 0;
- GetPlayerPos(playerid, X, Y, Z);
- for(new i=1;i<MAX_VEHICLES;i++)
- {
- if(GetVehicleModel(i) == 508)
- {
- new Float:fDistance = GetVehicleDistanceFromPoint(i, X, Y, Z);
- if(fDistance < 3.0)
- {
- count++;
- }
- if(count) RegisterVehicle(playerid, i);
- else
- {
- fDistance = GetVehicleDistanceFromPoint(i, ExitX[playerid], ExitY[playerid], ExitZ[playerid]);
- if(fDistance < 6.0)
- {
- RegisterVehicle(playerid, i);
- }
- }
- }
- }
- }
- }
- case DIALOG_JOURNEY_EDIT:
- {
- if(response)
- {
- new vID = pJInfo[playerid][jpID];
- switch(listitem)
- {
- case 0:
- {
- if(vJInfo[vID][Locked])
- {
- SendClientMessage(playerid, COLOR_NOTES2, "[NOTE] The vehicle is already locked!");
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_EDIT, DIALOG_STYLE_LIST, "{FFFFFF}Edit your {00C0FF}Journey", "{FFFFFF}Lock the {00C0FF}Journey\n{FFFFFF}Unlock the {00C0FF}Journey\n{FFFFFF}Disown the {00C0FF}Journey", "Select", "Close");
- }
- else
- {
- vJInfo[vID][Locked] = 1;
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] You've successfully locked your vehicle!");
- }
- }
- case 1:
- {
- if(!vJInfo[vID][Locked])
- {
- SendClientMessage(playerid, COLOR_NOTES2, "[NOTE] The vehicle isn't locked!");
- ShowPlayerDialog(playerid, DIALOG_JOURNEY_EDIT, DIALOG_STYLE_LIST, "{FFFFFF}Edit your {00C0FF}Journey", "{FFFFFF}Lock the {00C0FF}Journey\n{FFFFFF}Unlock the {00C0FF}Journey\n{FFFFFF}Disown the {00C0FF}Journey", "Select", "Close");
- }
- else
- {
- vJInfo[vID][Locked] = 0;
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] You've successfully unlocked your vehicle!");
- }
- }
- case 2:
- {
- ResetVehicleInfo(vID);
- SendClientMessage(playerid, COLOR_NOTES, "[INFO] You've successfully 'disowned' your vehicle!");
- }
- }
- }
- }
- }
- return 1;
- }
- //Journey stuff
- forward Unfreeze(playerid);
- public Unfreeze(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
- stock ResetVehicleInfo(vehicleid)
- {
- vJInfo[vehicleid][Owned] = 0, vJInfo[vehicleid][Locked] = 0;
- vJInfo[vehicleid][jvID] = vehicleid;
- foreach(Player, i)
- {
- if(pJInfo[i][jpID] == vJInfo[vehicleid][jvID])
- {
- pJInfo[i][jpID] = -1;
- if(pJInfo[i][InJourney])
- {
- new Float:X, Float:Y, Float:Z;
- GetVehiclePos(vehicleid, X, Y, Z);
- SetPlayerPos(i, X, Y+2, Z), SetPlayerVirtualWorld(i, 0);
- pJInfo[i][InJourney] = 0;
- }
- }
- }
- }
- stock ResetPlayerInfo(playerid)
- {
- pJInfo[playerid][jpID] = -1;
- pJInfo[playerid][InJourney] = 0;
- TimesEntered[playerid] = 0;
- }
- stock RegisterVehicle(playerid, vehicleid)
- {
- vJInfo[vehicleid][Owned] = 1, vJInfo[vehicleid][Locked] = 0;
- pJInfo[playerid][jpID] = vehicleid;
- vJInfo[vehicleid][jvID] = vehicleid;
- new string[98];
- format(string, sizeof(string), "[INFO] You're now the owner of Journey ID '%d'", pJInfo[playerid][jpID]);
- SendClientMessage(playerid, COLOR_NOTES, string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement