/transfer cmd
#1

Hello, could anyone help me to create /transfer cmd which would require to enter the exact name of player. Such as /transfer [Firstname_Lastname] [amount].

Thanks.
Reply
#2

Yako, What do you want inside the /transfer command?

-> Basic what you asked
Код:
CMD:transfer(playerid, params[])
{
	new giveplayerid, amount;
        if(sscanf(params, "ui[64]", giveplayerid,  amount)) return SendClientMessage(playerid, COLOR_WHITE,   "USAGE: /transfer [playerid] [amount]");
	if (giveplayerid == playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't do this command on yourself.");
	// Commmand....
	// -> Sscanf, ZCMD needed
	return 1;
}
Reply
#3

The command is good, but I want that it would require not playerid id but exact name such as Firstname_Lastname
Reply
#4

Well, use s[24] and then do loop that checking if there's any name online that you wrote.
Reply
#5

I wouldn't have written here if I knew how to create that command

Can anyone help me?
Reply
#6

CMD:transfer(playerid, params[])
{
new giveplayerid, amount;
if(sscanf(params, "si[64]", giveplayerid, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /transfer [Firstname_Lastname] [amount]");
if (giveplayerid == playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't do this command on yourself.");
// Commmand....
// -> Sscanf, ZCMD needed
return 1;
}
Reply
#7

like this http://pastebin.com/Qs6qyva4 ? , but not CMD
Reply
#8

pawn Код:
CMD:transfer(playerid, params[])
{
    new Target[MAX_PLAYER_NAME], amount, name[MAX_PLAYER_NAME], bool:found;
    if(sscanf(params, "s[MAX_PLAYER_NAME]d",  Target, amount))
    return SendClientMessage(playerid, -1, "USAGE: /transfer [Exact_Name] [amount]");
    for( new i = 0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof(name));
            if(strcmp(Target, name) == 0)
            {
                found = true;
                // You command here..
            }
        }
    }
    if(found == false) return SendClientMessage(playerid, -1, "ERROR: Use the exact player name!");
    return 1;
}
Not tested, was written in this chat, please try and reply here if it works.

NOTE: You need ZCMD and sscanf
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)