Command cash
#8

Try this, i made it in few minutes. Not sure if it works:
pawn Код:
stock GetIdFromName(playername[]) //Use this stock to use names instead of ids.
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            new pname[MAX_PLAYER_NAME];
            GetPlayerName(i,pname,MAX_PLAYER_NAME);
            if(strfind(pname,playername,true) != -1 && strlen(playername) != 0)
            {
                return i;
            }
        }
    }
    return -1;
}
So, for Example you are going to give cash to someone:

pawn Код:
dcmd_givecash( playerid, params[ ] )
{
        if(IsPlayerAdmin(playerid))
        {
            new string[26], mny;
            if(!sscanf(params,"s[26]i",string,mny))
            {
                if(IsPlayerConnected(rplayer))
                {
                new giveplayerid;
                giveplayerid = GetIdFromName(string);

                new pname[MAX_PLAYER_NAME], tomsg[60];
                GetPlayerName(playerid, pname, sizeof(pname));

                format(tomsg,sizeof(tomsg),"Admin %s gave you %i $!",pname,mny);

                GivePlayerMoney(giveplayerid , mny);

                SendClientMessage(giveplayerid, COLOR_GREEN, tomsg);

                } else return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
            } else return SendClientMessage(playerid, COLOR_RED, "Usage: /givecash [ part of name ] [ amount ]");
        }
        else SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
        return true;
}
This should work. but UNTESTED. xD
Reply


Messages In This Thread
Command cash - by ludesert - 27.06.2011, 07:55
Re: Command cash - by iPLEOMAX - 27.06.2011, 08:06
Re : Command cash - by ludesert - 27.06.2011, 08:17
Re: Command cash - by Basicz - 27.06.2011, 08:39
Re : Command cash - by ludesert - 27.06.2011, 09:14
Re : Re: Command cash - by ludesert - 27.06.2011, 10:15
Re : Re: Command cash - by ludesert - 27.06.2011, 10:21
Re: Command cash - by iPLEOMAX - 27.06.2011, 11:41
Re : Re: Command cash - by ludesert - 27.06.2011, 19:49
Re: Command cash - by iPLEOMAX - 27.06.2011, 19:53

Forum Jump:


Users browsing this thread: 3 Guest(s)