I want help with pay
#1

Edit: While waiting for the response that you got it made

How can I do to be able to send money only if the player who is sending money ahead of you.

Код:
dcmd_pay(playerid, params[])
{
    new otherid,cash,str[128],namez[MAX_PLAYER_NAME];
  if (sscanf(params, "ud", otherid, cash)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /pay [ID] [Cash]");
  else
  {
    if(GetPlayerMoney(playerid) < cash) SendClientMessage(playerid, COLOR_RED, "You don't have that much!");
    if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "That PlayerID is not connected!");
    if(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "It is pointless to pay yourself..");
    if(cash < 1) SendClientMessage(playerid, COLOR_RED, "You can not give less than 1 dollar!");
    else
    {
      GivePlayerMoney(playerid, -cash);
            GetPlayerName(playerid,namez,sizeof(namez));
            format(str,sizeof(str),"You have gained $%d from %s",cash,namez);
            SendClientMessage(otherid,COLOR_YELLOW,string);
    }
    {
      GivePlayerMoney(otherid, cash);
            GetPlayerName(playerid,namez,sizeof(namez));
            format(str,sizeof(str),"You have gained $%d from %s",cash,namez);
            SendClientMessage(otherid,COLOR_YELLOW,string);
    }
  }
  return 1;
}
Reply
#2

Код:
forward Float:PlayersDistance(P1, P2);

public Float:PlayersDistance(P1, P2) {
	new Float:XYZ[6];
	if(!IsPlayerConnected(P1) || !IsPlayerConnected(P2)) return -1.0;
	GetPlayerPos(P1,XYZ[0],XYZ[1],XYZ[2]);
	GetPlayerPos(P2,XYZ[3],XYZ[4],XYZ[5]);
	return floatsqroot(floatpower(floatabs(floatsub(XYZ[3],XYZ[0])),2)+floatpower(floatabs(floatsub(XYZ[4],XYZ[1])),2)+floatpower(floatabs(floatsub(XYZ[5],XYZ[2])),2));
}
After this you want to use an if statement in your command. Let me know if it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)