SA-MP Forums Archive
/givecash fail - 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: /givecash fail (/showthread.php?tid=517316)



/givecash fail - cleanboy - 04.06.2014

help me with this please, i cant use /givecash, says the player is far but its besides me.. heres my code

Код:
dcmd_givecash(playerid,params[])
{
	new string[128];
	new ID, amount;
    if(sscanf(params, "ui", ID, amount))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"USAGE: /givecash (Player Name/ID) (Amount)");
	    return 1;
	}
	if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
	if(IsFrozen[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
		format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot give money to them.",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
		return 1;
	}
	if(ID == playerid)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You cannot give money to yourself. Why would you waste your time?");
	    return 1;
	}
	if(GetPlayerMoney(playerid) < amount)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"You do not have that amount of money in order to give it to someone.");
	    return 1;
	}
	if(amount > 200000 || amount < 1000)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"Please enter an amount between $1000 and $200000.");
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) < 6)
	{
	    SendClientMessage(playerid,COLOR_ERROR,"That player is not close enough in order to give them money.");
	    return 1;
	}
	SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Money Given_]]");
	format(string,sizeof(string),"You have given $%d of your own money to %s(%d).",amount,PlayerName(ID),ID);
	SendClientMessage(playerid,COLOR_YELLOW,string);
	GivePlayerMoney(playerid,-amount);
	
	SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Money Received_]]");
	format(string,sizeof(string),"You have been given $%d by %s(%d). Make sure you thank them.",amount,PlayerName(playerid),playerid);
	SendClientMessage(ID,COLOR_YELLOW,string);
	GivePlayerMoney(ID,amount);
	
	format(string,sizeof(string),"2[CASH GIVEN] %s(%d) has given $%d to %s(%d).",PlayerName(playerid),playerid,amount,PlayerName(ID),ID);
	IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
	return 1;
}]




Re: /givecash fail - Parallex - 04.06.2014

Try this Bud:
pawn Код:
dcmd_givecash(playerid,params[])
{
    new string[128];
    new ID, amount;
    if(sscanf(params, "ui", ID, amount))
    {
        SendClientMessage(playerid,COLOR_ERROR,"USAGE: /givecash (Player Name/ID) (Amount)");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(IsKidnapped[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
        return 1;
    }
    if(IsFrozen[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot give money to them.",ID);
        SendClientMessage(playerid,COLOR_ERROR,string);
        return 1;
    }
    if(ID == playerid)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot give money to yourself. Why would you waste your time?");
        return 1;
    }
    if(GetPlayerMoney(playerid) < amount)
    {
        SendClientMessage(playerid,COLOR_ERROR,"You do not have that amount of money in order to give it to someone.");
        return 1;
    }
    if(amount > 200000 || amount < 1000)
    {
        SendClientMessage(playerid,COLOR_ERROR,"Please enter an amount between $1000 and $200000.");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 6)
    {
        SendClientMessage(playerid,COLOR_ERROR,"That player is not close enough in order to give them money.");
        return 1;
    }
    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Money Given_]]");
    format(string,sizeof(string),"You have given $%d of your own money to %s(%d).",amount,PlayerName(ID),ID);
    SendClientMessage(playerid,COLOR_YELLOW,string);
    GivePlayerMoney(playerid,-amount);
   
    SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Money Received_]]");
    format(string,sizeof(string),"You have been given $%d by %s(%d). Make sure you thank them.",amount,PlayerName(playerid),playerid);
    SendClientMessage(ID,COLOR_YELLOW,string);
    GivePlayerMoney(ID,amount);
   
    format(string,sizeof(string),"2[CASH GIVEN] %s(%d) has given $%d to %s(%d).",PlayerName(playerid),playerid,amount,PlayerName(ID),ID);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
    return 1;
}



Re: /givecash fail - cleanboy - 04.06.2014

what did u change there ben?


Re: /givecash fail - Parallex - 04.06.2014

Quote:
Originally Posted by cleanboy
Посмотреть сообщение
what did u change there ben?
Just go and see. I've made a difference. The Thing which was detecting the Distance is bugged. I've fixed it in my Game-Mode too long time ago.


Re: /givecash fail - cleanboy - 04.06.2014

ok bro, done! i will just see it tomorrow if it works


Re: /givecash fail - Affan - 04.06.2014

What you have.
pawn Код:
if(GetDistanceBetweenPlayers(playerid,ID) < 6)
    {
        SendClientMessage(playerid,COLOR_ERROR,"That player is not close enough in order to give them money.");
        return 1;
    }
What he changed.( He changed your less than sign to greater than sign.
pawn Код:
if(GetDistanceBetweenPlayers(playerid,ID) > 6)
    {
        SendClientMessage(playerid,COLOR_ERROR,"That player is not close enough in order to give them money.");
        return 1;
    }



Re: /givecash fail - cleanboy - 05.06.2014

oh okay,. thanks, ill see later if it works!