23.05.2014, 11:26
How do I create an order /levelbonus , anyone can use to enter the server and receive level 3 + 1.000.000$ ?
CMD:levelbonus(playerid,params[])
{
// you can use if condition here so players can use the command only once.
GivePlayerMoney(playerid, 1000000); // this will give the money
SetPlayerScore(playerid, 3); // this will set the score
return 1;
}
enum pInfo { pLevel, pCash } new PlayerInfo[MAX_PLAYERS][pInfo];
CMD:levelbonus(playerid,params[]) { if(PlayerInfo[playerid][pLevel]==3) { SendClientMessage(playerid,-1,"You already have Level 3 and 1,000,000$"); return 1; } else { PlayerInfo[playerid][pLevel]=3; GivePlayerMoney(playerid,1000000); PlayerInfo[playerid][pCash]=GetPlayerMoney(playerid); } return 1; }
public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]); INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]); INI_Close(File); return 1; }
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
new bool:bonusUsed[MAX_PLAYERS] = false;
CMD:levelbonus(playerid, params[])
{
#pragma unused params
if(bonusUsed[playerid]) return SCM(playerid, -1, "You've already used your level bonus.");
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3);
GivePlayerMoney(playerid, 1000000);
bonusUsed[playerid] = true;
return SCM(playerid, -1, "You've used your levelbonus ! You've gotten 3 levels more and $1'000'000 !");
}