SA-MP Forums Archive
Opinion on /buylevel command! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Opinion on /buylevel command! (/showthread.php?tid=664420)



Opinion on /buylevel command! - bosmania - 28.02.2019

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


Re: Opinion on /buylevel command! - benjaminjones - 28.02.2019

Command works to be working properly, even though its hard to read in the way you pasted it. You have your variables, checking conditions. The only think I dont understand is, why do you send everybody a message about player leveling up?


Re: Opinion on /buylevel command! - bosmania - 28.02.2019

For the sake of it,i don't know, and it doesn't send everyone,it sends only to the players that are in a 5.0 radius,that's what ProxDetector function does