How to ... ?
#1

Hey, I want to make /pay command using ProxDetector, can you make it, here are few things that may help you.

Код:
ProxDetector(40.0, playerid, str, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
Код:
SendClientMessage(playerid, COLOR_GREY, "USAGE: /pay [PlayerID/PartofName] [Amount]");
SendClientMessage(playerid,COLOR_GREY, "You do not have that amount of money.");
SendClientMessage(playerid,COLOR_GREY, "The player ID/Name entered is INVALID.");
Format for all players near 40 meters:
Код:
"%s takes out some money and gives it to %s"
And for the receiver:
Код:
"You have recieved $%i from %s"
Reply
#2

untested but should work

pawn Код:
CMD:pay(playerid,params[])
{
    new amount, name[MAX_PLAYER_NAME];
    if(sscanf(params,"s[24]d",name,amount)) return SendClientMessage(playerid,COLOR_GREY,"use: /pay name amount (note this command doesn't do anything)");
    new s[64];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(s,sizeof(s),"%s takes out some money and gives it to %s",pname,name);
    ProxDetector(40.0, playerid, s, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
}
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
untested but should work

pawn Код:
CMD:pay(playerid,params[])
{
    new amount, name[MAX_PLAYER_NAME];
    if(sscanf(params,"s[24]d",name,amount)) return SendClientMessage(playerid,COLOR_GREY,"use: /pay name amount (note this command doesn't do anything)");
    new s[64];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(s,sizeof(s),"%s takes out some money and gives it to %s",pname,name);
    ProxDetector(40.0, playerid, s, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
}
You didn't do anything with the amount ^^.
pawn Код:
COMMAND:pay(playerid, params[])
{
  new target, amount;
  if(sscanf(params, "ui", target, amount)) return SendClientMessage(playerid, 0x00ff0fff, "USAGE: /pay [playerid/name] [monies]");
  else if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0x00ff0fff, "Enter a valid player!");
  else if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0x00ff0fff, "You haven't got enough monies to give!");
  GivePlayerMoney(target, amount);
  GivePlayerMoney(playerid, -amount);
  new string[128], pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  GetPlayerName(target, string, MAX_PLAYER_NAME);
  format(string, sizeof string, "%s takes out some money and gives it to %s", pName, string);
  ProxDetector(40.0, playerid, str, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
  format(string, sizeof string, "You have received %i monies from %s!", amount, pName);
  SendClientMessage(target, 0xff0fffff, string);
  return 1;
}
Untested either
Reply
#4

Can you make it using strcmp?
With this I get
Код:
D:\Games\Grand Theft Auto (GTA) San Andreas-HOODLUM\ROLE FUCKING PLAY\gamemodes\VRP.pwn(525) : error 029: invalid expression, assumed zero
D:\Games\Grand Theft Auto (GTA) San Andreas-HOODLUM\ROLE FUCKING PLAY\gamemodes\VRP.pwn(525) : error 017: undefined symbol "cmd_pay"
D:\Games\Grand Theft Auto (GTA) San Andreas-HOODLUM\ROLE FUCKING PLAY\gamemodes\VRP.pwn(525) : error 029: invalid expression, assumed zero
D:\Games\Grand Theft Auto (GTA) San Andreas-HOODLUM\ROLE FUCKING PLAY\gamemodes\VRP.pwn(525) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Line 525 is:
Код:
COMMAND:pay(playerid, params[])
Reply
#5

Just put the pay thingy in strcmp, and replace all the "params" with "cmdtext" in the command.
Reply
#6

Dude I already made the fucking command for you.
pawn Код:
CMD:pay(playerid, params[])
{
    new giveplayerid, gamount, name1, name2, Float:X,Float:Y,Float:Z;
    if(sscanf,"ui",giveplayerid, gamount) return SendClientMessage(playerid, 0xFF0000, "USAGE: /pay [PlayerID/PartofName] [Amount]");
    if(GetPlayerMoney(playerid) < gamount) return SendClientMessage(playerid,0xFF0000, "You do not have that amount of money.");
    if(giveplayerid = INVALID_PLAYER_ID) return SendClientMessage(playerid,0xFF0000, "The player ID/Name entered is INVALID.");
    GetPlayerName(playerid, name1, sizeof(name1));
    GetPlayerName(giveplayerid, name2, sizeof(name2));
    GetPlayerPos(playerid,X,Y,Z);
    foreach(Player, i)
    {
        If(IsPlayerInRangeOfPoint(i,40.0,X,Y,Z)
        {
            new msg[128];
            format(msg,sizeof(msg),"%s takes out some money and gives it to %s", name1, name2);
            SendClientMessage(i,0xD900FF,msg);
            new msg2[100];
            format(msg2,sizeof(msg2),"You have recieved $%i from %s", gamount, name1);
            SendClientMessage(giveplayerid, 0xFFFFFF, msg2);
            return 1;
        }
    }
    return 1;
}
Reply
#7

Код:
if(!strcmp(cmdtext, "/pay", true))
	{
	new target, amount;
	if(sscanf(cmdtext, "ui", target, amount))
	return SendClientMessage(playerid, 0x00ff0fff, "USAGE: /pay [playerid/name] [money]");
	else if(target == INVALID_PLAYER_ID)
	return SendClientMessage(playerid, 0x00ff0fff, "Enter a valid player!");
	else if(amount > GetPlayerMoney(playerid))
	return SendClientMessage(playerid, 0x00ff0fff, "You haven't got enough money to give!");
	GivePlayerMoney(target, amount);  GivePlayerMoney(playerid, -amount);
	new string[128], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	GetPlayerName(target, string, MAX_PLAYER_NAME);  format(string, sizeof string, "%s takes out some money and gives it to %s", pName, string);
	ProxDetector(40.0, playerid, str, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
	format(string, sizeof string, "You have received %i monies from %s!", amount, pName);
	SendClientMessage(target, 0xff0fffff, string);
	return 1;
	}
Код:
D:\Games\Grand Theft Auto (GTA) San Andreas-HOODLUM\ROLE FUCKING PLAY\gamemodes\VRP.pwn(313) : error 017: undefined symbol "str"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Line 313:
Код:
ProxDetector(40.0, playerid, str, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
Reply
#8

new str[128] perhaps ?
Reply
#9

You forgot to add "str".
pawn Код:
if(!strcmp(cmdtext, "/pay", true))
{
    new target, amount, str[128];
    if(sscanf(cmdtext, "ui", target, amount))
        return SendClientMessage(playerid, 0x00ff0fff, "USAGE: /pay [playerid/name] [money]");
    else if(target == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, 0x00ff0fff, "Enter a valid player!");
    else if(amount > GetPlayerMoney(playerid))
        return SendClientMessage(playerid, 0x00ff0fff, "You haven't got enough money to give!");
    GivePlayerMoney(target, amount);  GivePlayerMoney(playerid, -amount);
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(target, string, MAX_PLAYER_NAME);  format(string, sizeof string, "%s takes out some money and gives it to %s", pName, string);
    ProxDetector(40.0, playerid, str, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
    format(string, sizeof string, "You have received %i monies from %s!", amount, pName);
    SendClientMessage(target, 0xff0fffff, string);
    return 1;
}
Reply
#10

No errors, but the command doesn't work IG
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)