From 6e67f304776dd2c769fa45116cf102bc546a137a Mon Sep 17 00:00:00 2001 From: Sultan1337 <51270951+Sultan1337@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:10:46 +0500 Subject: [PATCH 1/4] Add /perks --- gamemodes/core/cmds/cmds.inc | 1 + gamemodes/core/cmds/cmds_perks.inc | 83 ++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 gamemodes/core/cmds/cmds_perks.inc diff --git a/gamemodes/core/cmds/cmds.inc b/gamemodes/core/cmds/cmds.inc index 0ad8f2a..3d77e11 100644 --- a/gamemodes/core/cmds/cmds.inc +++ b/gamemodes/core/cmds/cmds.inc @@ -8,6 +8,7 @@ #include // private message #include #include +#include #include diff --git a/gamemodes/core/cmds/cmds_perks.inc b/gamemodes/core/cmds/cmds_perks.inc new file mode 100644 index 0000000..ade1856 --- /dev/null +++ b/gamemodes/core/cmds/cmds_perks.inc @@ -0,0 +1,83 @@ +#define DIALOG_PERKS 69 + +enum + E_PERKS_DATA + { + E_NAME[32], E_PURPOSE[64], + E_COST + } +; + +static + gPerkData[][E_PERKS_DATA] = + { + {"Repair Vehicle", "Restores a vehicle's health to 1000", 5000}, + {"Flip Vehicle", "Flips a vehicle back to wheels if it's backflipped", 1000}, + {"Add NOS", "Adds a NOS to vehicle", 4000} + } +; + +CMD:perks(playerid, params[]) +{ + if(!IsPlayerInAnyVehicle(playerid)) + return SendErrorMsg(playerid, "You must be in a vehicle to use this command."); + + new + perksStr[256] + ; + + for(new i = 0; i < sizeof(gPerkData); i++) + format(perksStr, sizeof perksStr, "%s%s\t%s\t{FFDC2E}$%d\n", perksStr, gPerkData[i][E_NAME], gPerkData[i][E_PURPOSE], gPerkData[i][E_COST]); + + format(perksStr, sizeof perksStr, "{FFFFFF}Perk\t{FFFFFF}Purpose\t{FFFFFF}Cost\n%s", perksStr); + + ShowPlayerDialog(playerid, DIALOG_PERKS, DIALOG_STYLE_TABLIST_HEADERS, "Player Perks", perksStr, "Choose", "Close"); + return 1; +} + +public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) +{ + if(dialogid == DIALOG_PERKS) + { + new + vehicleid = GetPlayerVehicleID(playerid) + ; + + switch (listitem) + { + case 0: // Repair vehicle + { + if(!IsPlayerInAnyVehicle(playerid)) // Somehow left vehicle? + return SendErrorMsg(playerid, "You must be in a vehicle to use this feature."); + + RepairVehicle(vehicleid); + + SendMsgF(playerid, -1, "[VEH-FIX] You have fixed your vehicle for {FFDC2E}$%d", gPerkData[listitem][E_COST]); + } + case 1: // Flip vehicle + { + if(!IsPlayerInAnyVehicle(playerid)) // Somehow left vehicle? + return SendErrorMsg(playerid, "You must be in a vehicle to use this feature."); + + new + Float:VehZAngle + ; + + GetVehicleZAngle(vehicleid, VehZAngle); + SetVehicleZAngle(vehicleid, VehZAngle); + + SendMsgF(playerid, -1, "[VEH-FLIP] You have flipped your vehicle for {FFDC2E}$%d", gPerkData[listitem][E_COST]); + } + case 2: // Add NOS + { + if(!IsPlayerInAnyVehicle(playerid)) // Somehow left vehicle? + return SendErrorMsg(playerid, "You must be in a vehicle to use this feature."); + + AddVehicleComponent(vehicleid, 1010); + + SendMsgF(playerid, -1, "[VEH-NOS] You have installed NOS your vehicle for {FFDC2E}$%d", gPerkData[listitem][E_COST]); + } + } + } + return 1; +} From d2abf22c4269a2aef5f8cdde3b036d9497a71441 Mon Sep 17 00:00:00 2001 From: Sultan1337 <51270951+Sultan1337@users.noreply.github.com> Date: Mon, 25 Jan 2021 22:44:04 +0500 Subject: [PATCH 2/4] Add TP option in /perks --- gamemodes/core/cmds/cmds_perks.inc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gamemodes/core/cmds/cmds_perks.inc b/gamemodes/core/cmds/cmds_perks.inc index ade1856..20417f5 100644 --- a/gamemodes/core/cmds/cmds_perks.inc +++ b/gamemodes/core/cmds/cmds_perks.inc @@ -1,4 +1,5 @@ #define DIALOG_PERKS 69 +#define DIALOG_PERKS_TP 6970 enum E_PERKS_DATA @@ -13,7 +14,8 @@ static { {"Repair Vehicle", "Restores a vehicle's health to 1000", 5000}, {"Flip Vehicle", "Flips a vehicle back to wheels if it's backflipped", 1000}, - {"Add NOS", "Adds a NOS to vehicle", 4000} + {"Add NOS", "Adds a NOS to vehicle", 4000}, + {"Teleportation", "You can teleport to any player", 1000} } ; @@ -77,7 +79,32 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) SendMsgF(playerid, -1, "[VEH-NOS] You have installed NOS your vehicle for {FFDC2E}$%d", gPerkData[listitem][E_COST]); } + case 3: // Teleport + { + ShowPlayerDialog(playerid, DIALOG_PERKS_TP, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + } } } + else if(dialogid == DIALOG_PERKS_TP) + { + new + id + ; + + if(sscanf(inputtext, "u", id)) + return ShowPlayerDialog(playerid, DIALOG_PERKS_TP, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + + else if(!IsPlayerConected(id)) + return SendErrorMsg(playerid, "Invalid Player ID"); + + else if(GetPlayerWantedLevel(playerid) != 0) + return SendErrorMsg(playerid, "You mustn't be a wanted player to use this perk."); + + new Float:x, Float:y, Float:z; + GetPlayerPos(id, x, y, z); + SetPlayerPos(playerid, x, y, z); + + SendMsgF(playerid -1, "[PERK-TP] You have successfully teleported to %s", id); + } return 1; } From 894a00892875f970e73fc09a8a54b940a09aa95b Mon Sep 17 00:00:00 2001 From: Sultan1337 <51270951+Sultan1337@users.noreply.github.com> Date: Mon, 25 Jan 2021 22:48:50 +0500 Subject: [PATCH 3/4] Remove is not in vehicle restriction in the CMD --- gamemodes/core/cmds/cmds_perks.inc | 3 --- 1 file changed, 3 deletions(-) diff --git a/gamemodes/core/cmds/cmds_perks.inc b/gamemodes/core/cmds/cmds_perks.inc index 20417f5..86a4c15 100644 --- a/gamemodes/core/cmds/cmds_perks.inc +++ b/gamemodes/core/cmds/cmds_perks.inc @@ -21,9 +21,6 @@ static CMD:perks(playerid, params[]) { - if(!IsPlayerInAnyVehicle(playerid)) - return SendErrorMsg(playerid, "You must be in a vehicle to use this command."); - new perksStr[256] ; From 8e0f06178063292f1cb0e53b41abfe92281e24f3 Mon Sep 17 00:00:00 2001 From: CnR XomoX <55300557+CnRXoMoX@users.noreply.github.com> Date: Sun, 14 Feb 2021 00:00:09 +0800 Subject: [PATCH 4/4] Changes using inlines perks cmd --- gamemodes/core/cmds/cmds_perks.inc | 73 ++++++++++++++------------ gamemodes/core/player/player_items.inc | 4 +- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/gamemodes/core/cmds/cmds_perks.inc b/gamemodes/core/cmds/cmds_perks.inc index 86a4c15..f5922e4 100644 --- a/gamemodes/core/cmds/cmds_perks.inc +++ b/gamemodes/core/cmds/cmds_perks.inc @@ -25,19 +25,9 @@ CMD:perks(playerid, params[]) perksStr[256] ; - for(new i = 0; i < sizeof(gPerkData); i++) - format(perksStr, sizeof perksStr, "%s%s\t%s\t{FFDC2E}$%d\n", perksStr, gPerkData[i][E_NAME], gPerkData[i][E_PURPOSE], gPerkData[i][E_COST]); - - format(perksStr, sizeof perksStr, "{FFFFFF}Perk\t{FFFFFF}Purpose\t{FFFFFF}Cost\n%s", perksStr); - - ShowPlayerDialog(playerid, DIALOG_PERKS, DIALOG_STYLE_TABLIST_HEADERS, "Player Perks", perksStr, "Choose", "Close"); - return 1; -} - -public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) -{ - if(dialogid == DIALOG_PERKS) - { + inline perks(pid, dialogid, response, listitem, string:inputtext[]) { + #pragma unused pid, dialogid, inputtext + if(!response) return 1; new vehicleid = GetPlayerVehicleID(playerid) ; @@ -78,30 +68,45 @@ public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) } case 3: // Teleport { - ShowPlayerDialog(playerid, DIALOG_PERKS_TP, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + inline teleportInline(pid2, did, resp, li, string:it[]) { + #pragma unused pid2, did, li + new + id + ; + + if(!resp) return Dialog_ShowCallback(playerid, using inline teleportInline, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + + if(sscanf(it, "u", id)) { + return Dialog_ShowCallback(playerid, using inline teleportInline, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + } + + else if(!IsPlayerConnected(id)) { + return SendErrorMsg(playerid, "Invalid Player ID"); + } + + else if(GetPlayerWantedLevel(playerid) != 0) { + return SendErrorMsg(playerid, "You mustn't be a wanted player to use this perk."); + } + + new Float:x, Float:y, Float:z; + new interior = GetPlayerInterior(playerid), vm = GetPlayerVirtualWorld(playerid); + GetPlayerPos(id, x, y, z); + SetPlayerPos(playerid, x, y, z); + SetPlayerInterior(playerid, interior); + SetPlayerVirtualWorld(playerid, vm); + + SendMsgF(playerid, -1, "[PERK-TP] You have successfully teleported to %s", id); + } + Dialog_ShowCallback(playerid, using inline teleportInline, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); } } } - else if(dialogid == DIALOG_PERKS_TP) - { - new - id - ; - if(sscanf(inputtext, "u", id)) - return ShowPlayerDialog(playerid, DIALOG_PERKS_TP, DIALOG_STYLE_INPUT, "{FFFFFF}Teleport To A Player", "Input a valid player name/id", "Select", "Cancel"); + for(new i = 0; i < sizeof(gPerkData); i++) + format(perksStr, sizeof perksStr, "%s%s\t%s\t{FFDC2E}$%d\n", perksStr, gPerkData[i][E_NAME], gPerkData[i][E_PURPOSE], gPerkData[i][E_COST]); - else if(!IsPlayerConected(id)) - return SendErrorMsg(playerid, "Invalid Player ID"); + format(perksStr, sizeof perksStr, "{FFFFFF}Perk\t{FFFFFF}Purpose\t{FFFFFF}Cost\n%s", perksStr); - else if(GetPlayerWantedLevel(playerid) != 0) - return SendErrorMsg(playerid, "You mustn't be a wanted player to use this perk."); - - new Float:x, Float:y, Float:z; - GetPlayerPos(id, x, y, z); - SetPlayerPos(playerid, x, y, z); - - SendMsgF(playerid -1, "[PERK-TP] You have successfully teleported to %s", id); - } - return 1; -} + Dialog_ShowCallback(playerid, using inline perks, DIALOG_STYLE_TABLIST_HEADERS, "Player Perks", perksStr, "Choose", "Close"); + return 1; +} \ No newline at end of file diff --git a/gamemodes/core/player/player_items.inc b/gamemodes/core/player/player_items.inc index 28715ba..05e01ce 100644 --- a/gamemodes/core/player/player_items.inc +++ b/gamemodes/core/player/player_items.inc @@ -179,8 +179,8 @@ static void:_SaveItem(playerid, const itemName[], value) { "UPDATE player_items SET ? = ? + ? WHERE u_id = ?" ); - MySQL_Bind(stmt_saveItem, 0, itemName, true); - MySQL_Bind(stmt_saveItem, 1, itemName, true); + MySQL_Bind(stmt_saveItem, 0, itemName); + MySQL_Bind(stmt_saveItem, 1, itemName); MySQL_BindInt(stmt_saveItem, 2, value); MySQL_BindInt(stmt_saveItem, 3, Player_GetAccountID(playerid)); MySQL_ExecuteThreaded(stmt_saveItem);