27.06.2011, 11:41
Try this, i made it in few minutes. Not sure if it works:
So, for Example you are going to give cash to someone:
This should work. but UNTESTED. xD
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;
}
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;
}