SA-MP Forums Archive
Help wiki /givemoney - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help wiki /givemoney (/showthread.php?tid=377613)



Help wiki /givemoney - Fernado - 14.09.2012

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) {



Re: Help wiki /givemoney - KoczkaHUN - 15.09.2012

Quote:
Originally Posted by Fernado
Посмотреть сообщение
how can i make this command only for logged in player?
pawn Код:
CMD:givemoney(playerid,params[]) {
        if(PlayerInfo[playerid][LoggedIn] != 1) return SendMessageToPlayer(playerid, COLOR_BRIGHTRED, "You are not logged in.");
....
}