Last active
February 16, 2019 13:53
-
-
Save CodeAlDente/d7672e102511e4b2cf3c to your computer and use it in GitHub Desktop.
Returns the name of the rank of a trucker (PPC Trucking GM)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PPC_Defines.inc | |
// Define trucker ranks | |
enum TTruckerRanks | |
{ | |
RankStats, // Holds the required stats to get this rank | |
RankName[50] // Holds the name of the rank | |
} | |
new ATruckerRanks[][TTruckerRanks] = | |
{ | |
{0, "Alpha"}, | |
{10, "Beta"}, | |
{20, "Gamma"}, | |
{30, "Delta"}, | |
{40, "Epsilon"}, | |
{50, "Zeta"}, | |
{60, "Theta"}, | |
{70, "Iota"}, | |
{80, "Kappa"}, | |
{90, "Lamda"} | |
}; | |
// PPC_PlayerCommands.inc | |
// This command shows your rank | |
COMMAND:rank(playerid,params[]) | |
{ | |
// Setup local variables | |
new Msg[128]; | |
// Send the command to all admins so they can see it | |
SendAdminText(playerid, "/rank", params); | |
// Check if the player has logged in | |
if (APlayerData[playerid][LoggedIn] == true) | |
{ | |
if (APlayerData[playerid][PlayerClass] == ClassTruckDriver) | |
{ | |
format(Msg, sizeof(Msg), "Your rank is: %s", GetTruckerRank(APlayerData[playerid][StatsTruckerJobs])); | |
SendClientMessage(playerid, 0x0000FFFF, Msg); | |
} | |
else | |
return 0; | |
} | |
else | |
return 0; | |
// Let the server know that this was a valid command | |
return 1; | |
} | |
// PPC_Common.inc | |
GetTruckerRank(Jobs) { | |
new Rank[50]; | |
for (new i = 0; i < sizeof(ATruckerRanks); i++) | |
{ | |
// Check for the minimum rank stats and assign the rank name | |
if (ATruckerRanks[i][RankStats] <= Jobs) { | |
format(Rank, sizeof(Rank), ATruckerRanks[i][RankName]); | |
} | |
} | |
return Rank; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment