Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /perks #53

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gamemodes/core/cmds/cmds.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cmds_pm> // private message
#include <cmds_bank>
#include <cmds_gang>
#include <cmds_perks>

#include <cmds_rob>

Expand Down
112 changes: 112 additions & 0 deletions gamemodes/core/cmds/cmds_perks.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#define DIALOG_PERKS 69
#define DIALOG_PERKS_TP 6970

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},
{"Teleportation", "You can teleport to any player", 1000}
}
;

CMD:perks(playerid, params[])
{
new
perksStr[256]
;

inline perks(pid, dialogid, response, listitem, string:inputtext[]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline function name is CameCase.

#pragma unused pid, dialogid, inputtext
if(!response) return 1;
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]);
}
case 3: // Teleport
{
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");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consitency


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");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistency, which style do you want to use?

}

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");
}
}
}

for(new i = 0; i < sizeof(gPerkData); i++)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we wrap this in brackets please?

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);

Dialog_ShowCallback(playerid, using inline perks, DIALOG_STYLE_TABLIST_HEADERS, "Player Perks", perksStr, "Choose", "Close");
return 1;
}
4 changes: 2 additions & 2 deletions gamemodes/core/player/player_items.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed to allow raw string to be the input

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When i compiled it, gives me an error but gonna fix it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update package sampctl p ensure because I've recently updated the prepared statement library.

MySQL_BindInt(stmt_saveItem, 2, value);
MySQL_BindInt(stmt_saveItem, 3, Player_GetAccountID(playerid));
MySQL_ExecuteThreaded(stmt_saveItem);
Expand Down