28.02.2019, 12:48
What is you honest opinion on this /buylevel command,and if it can be improved,how do i improve it?
CMD:buylevel(playerid, params[])
{
new string[64],string2[64],string3[64];
new lvlcost = 1500 * PlayerInfo[playerid][pLevel];
new nextlvl = PlayerInfo[playerid][pLevel] + 1;
new nxtlvlrp = 3 * PlayerInfo[playerid][pLevel];
new lvlrp = PlayerInfo[playerid][pRespect];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first");
if(PlayerInfo[playerid][pMoney] < lvlcost) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
format(string2,sizeof(string2), "You don't have enough respect points (%d/%d)", lvlrp,nxtlvlrp);
if(PlayerInfo[playerid][pRespect] < nxtlvlrp) return SendClientMessage(playerid, COLOR_GREY, string2);
PlayerInfo[playerid][pLevel] +=1;
PlayerInfo[playerid][pRespect] -= nxtlvlrp;
UpdateVariable(playerid, pRespectx);
UpdateVariable(playerid, pLevelx);
GivePlayerMoneyEx(playerid, -lvlcost);
UpdateVariable(playerid, pMoneyx);
format(string,sizeof(string), "Your level is now %d", nextlvl);
SendClientMessage(playerid, COLOR_YELLOW, string);
foreach(Player, i)
{
format(string3, sizeof(string3), "%s now has level %d",GetName(playerid), PlayerInfo[playerid][pLevel]);
ProxDetector(i,COLOR_PURPLE, string3);
}
return 1;
}
CMD:buylevel(playerid, params[])
{
new string[64],string2[64],string3[64];
new lvlcost = 1500 * PlayerInfo[playerid][pLevel];
new nextlvl = PlayerInfo[playerid][pLevel] + 1;
new nxtlvlrp = 3 * PlayerInfo[playerid][pLevel];
new lvlrp = PlayerInfo[playerid][pRespect];
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first");
if(PlayerInfo[playerid][pMoney] < lvlcost) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
format(string2,sizeof(string2), "You don't have enough respect points (%d/%d)", lvlrp,nxtlvlrp);
if(PlayerInfo[playerid][pRespect] < nxtlvlrp) return SendClientMessage(playerid, COLOR_GREY, string2);
PlayerInfo[playerid][pLevel] +=1;
PlayerInfo[playerid][pRespect] -= nxtlvlrp;
UpdateVariable(playerid, pRespectx);
UpdateVariable(playerid, pLevelx);
GivePlayerMoneyEx(playerid, -lvlcost);
UpdateVariable(playerid, pMoneyx);
format(string,sizeof(string), "Your level is now %d", nextlvl);
SendClientMessage(playerid, COLOR_YELLOW, string);
foreach(Player, i)
{
format(string3, sizeof(string3), "%s now has level %d",GetName(playerid), PlayerInfo[playerid][pLevel]);
ProxDetector(i,COLOR_PURPLE, string3);
}
return 1;
}