SA-MP Forums Archive
local variable and public function lacks errors - 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: local variable and public function lacks errors (/showthread.php?tid=588378)



local variable and public function lacks errors - PowerF - 08.09.2015

Код:
dcmd_adgivecash(playerid,params[])
{
	new ID;
	new Cash;
	new string[128];
    if(sscanf(params,"ui",ID,Cash))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"USAGE: /adg(ive)c(ash) (Player Name/ID) (Amount)");
	    return 1;
	}
	if(IsSpawned[ID] == 0)
	{
	    format(string,sizeof(string),"%s(%d) is must be alive and spawned in order to give them cash.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	GivePlayerCash(ID,Cash);
	format(string,sizeof(string),"[ADMIN CASH] Administrator has given you Cash. Amount: %d.",Cash);
	SendClientMessage(ID,COLOR_ADMIN,string);

	format(string,sizeof(string),"[ADMIN CASH] You have given %s(%d) Cash. Amount: %d.",PlayerName(ID),ID,Cash);
	SendClientMessage(playerid,COLOR_ADMIN,string);

	format(string,sizeof(string),"9[ADMIN CASH] Administrator %s(%d) has given %s(%d) Cash. Amount: %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,Cash);
	IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string);
	return 1;
}
and

Код:
public MoneyTimer()
{
	new username[MAX_PLAYER_NAME];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(GetPlayerCash(i) != GetPlayerMoney(i))
			{
				ResetMoneyBar(i);//Resets the money in the original moneybar, Do not remove!
				UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove!
				new hack = GetPlayerMoney(i) - GetPlayerCash(i);
				GetPlayerName(i,username,sizeof(username));
				printf("%s has picked up/attempted to spawn $%d.", username,hack);
			}
		}
	}
}
any help?


Re: local variable and public function lacks errors - BKarner - 08.09.2015

I'm confused. The problem is that it /LACKS/ errors?


Re: local variable and public function lacks errors - saffierr - 08.09.2015

All those return 1; is kinda useless, remove them except THE last one


Re: local variable and public function lacks errors - IceBilizard - 08.09.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
All those return 1; is kinda useless, remove them except THE last one
if he removed return 1; from if else conditions then command will works if there are any if else conditions like any player is not connected then it will show player is not connected but command will works