Commands with Parameters return Unknown Command with 0.3e
#1

When i do the command in 0.3e i get SERVER: Unknown Command!
COMMAND:tranfer(playerid,params[])
{
new senderid,recieverid,amount;
if (sscanf(params, "uui",senderid,recieverid,amount)) return SendClientMessage(playerid, 0xFFFFFFFF,"Correct Usage: /transfer senderid recieverid amount");
GivePlayerMoney(senderid,-amount);
GivePlayerMoney(recieverid,amount);
SendClientMessage(playerid,0xFF0000FF,"Money Transferred!");
return 1;
}
Reply
#2

senderid is really necessary?
Reply
#3

Try this,i use this command for my CNR gamemode and it works good.I've added some checks on it.

pawn Код:
CMD:transfer(playerid, params[])
{
    new Destinationid,Ammount,PlayerName[24],DestName[24],String[128];
    if (sscanf(params, "ui", Destinationid, Ammount)) return SendClientMessage(playerid, -1, "Usage: /transfer <playerid> <ammount>");
    if (!IsPlayerConnected(Destinationid)) return SendClientMessage(playerid, -1, "Player is not connected.");
    if (GetPlayerMoney(playerid) < Ammount) return SendClientMessage(playerid, -1, "Insufficent funds.");
    if(playerid == Destinationid) return SendClientMessage(playerid,red, "You can't send money to yourself.");
    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destinationid, DestName, 24);
    format(String, 128, "%s (%d) has sent you %d$", PlayerName, playerid, Ammount);
    SendClientMessage(Destinationid, -1, String);
    new gmsent[128];
    format(gmsent,sizeof(gmsent),"Sent %d$ to %s (%d)", Ammount,DestName,Destinationid);
    GameTextForPlayer(playerid,gmsent,3000,5);
    format(String, 128, "You've sent %d$ to %s (%d)", Ammount, DestName, Destinationid);
    SendClientMessage(playerid, -1, String);
    GivePlayerMoney(Destinationid, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)