Help wiki /givemoney
#1

how can i make this command only for logged in player?

pawn Код:
CMD:givemoney(playerid,params[]) {
    new Moneys,giveplayerid,giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],playerMoney[MAX_PLAYERS],string[64];
    new tmp3[50]; GetPlayerIp(playerid,tmp3,50);
    if (sscanf(params, "ud",giveplayerid, Moneys)) return SendMessageToPlayer(playerid, COLOR_LIGHTBLUE, "USAGE: /gc [playerid] [amount]");
//  if (!IsNumeric(giveplayerid)) giveplayerid = ReturnPlayerID(giveplayerid);
    if (IsPlayerConnected(giveplayerid)) {
        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        playerMoney[playerid] = GetPlayerMoney(playerid);
        if (Moneys > 0 && playerMoney[playerid] >= Moneys) {
            GivePlayerMoney(playerid, (-Moneys));
            GivePlayerMoney(giveplayerid, Moneys);
            format(string, sizeof(string), "You have sent %s (id: %d), $%d.", giveplayer,giveplayerid, Moneys);
            SendMessageToPlayer(playerid, green, string);
            format(string, sizeof(string), "You have recieved $%d from %s (id: %d).", Moneys, sendername, playerid);
            SendMessageToPlayer(giveplayerid, green, string);
            printf("%s(playerid:%d) has transfered $ %d to %s(playerid:%d)",sendername, playerid, Moneys, giveplayer, giveplayerid);
            format(string, 256, "* %s(playerid:%d) has transfered $ %d to %s(playerid:%d)",sendername, playerid, Moneys, giveplayer, giveplayerid);
            SendClientMessageToAll(COLOR_BRIGHTRED, string );}
        else {
            SendMessageToPlayer(playerid, COLOR_BRIGHTRED, "Invalid transaction amount.");}}
    else {
        format(string, sizeof(string), "ID:%d is not an active player.", giveplayerid);
        SendMessageToPlayer(playerid, COLOR_BRIGHTRED, string);}
    return 1;}
loggedin code
pawn Код:
if(PlayerInfo[playerid][LoggedIn] == 1) {
Reply


Messages In This Thread
Help wiki /givemoney - by Fernado - 14.09.2012, 23:57
Re: Help wiki /givemoney - by KoczkaHUN - 15.09.2012, 00:09

Forum Jump:


Users browsing this thread: 1 Guest(s)