/givecash [playername] [money] -
Vvolk - 12.05.2011
Please someone give me working and tested code to make command like this: /givecash [playername] [amount], /givexp [playername] [amount]...

I will be very grateful
Re: /givecash [playername] [money] -
SkizzoTrick - 12.05.2011
pawn Код:
if(strcmp(cmd, "/money", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "/money [playerid/PartOfName] [money] - give a player a specific money value.");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
money = strval(tmp);
if(IsPlayerConnected(playa))
{
new pname[MAX_PLAYER_NAME];
if(playa != INVALID_PLAYER_ID)
{
GivePlayerMoney(playa, money);
GetPlayerName(playa, pname, sizeof(pname));
format(string, sizeof(string), "You gave %s %d money", pname,money);
SendClientMessage(playerid, COLOR_ORANGE, string);
}
}
}
return 1;
}
Re: /givecash [playername] [money] -
black_dota - 12.05.2011
You will need sscanf and zcmd
pawn Код:
CMD:givecash(playerid, params[])
{
new
pMsg[74],
pID,
Money;
if(sscanf(params, "ui", pID, Money)) return SendClientMessage(playerid, 0xFFFFFFAA, "{FF6600}Use: {FFFFFF}/givecash [playerid/Name-ID] [Money]");
{
GivePlayerMoney(pID, Money);
format(pMsg, 74, "{8B8989}INFO: {FFFFFF}%s has gave you $%i.", GetName(playerid), Money);
SendClientMessage(pID, 0xFFFFFFAA, pMsg);
format(pMsg, 74, "{8B8989}INFO: {FFFFFF}You gave $%i to player %s.", Money, GetName(pID));
SendClientMessage(playerid, 0xFFFFFFAA, pMsg);
}
return true;
}
stock GetName(playerid)
{
new
pName[24];
GetPlayerName(playerid, pName, 24);
return pName;
}
Re: /givecash [playername] [money] -
SkizzoTrick - 12.05.2011
Quote:
Originally Posted by black_dota
You will need sscanf and zcmd
pawn Код:
CMD:givecash(playerid, params[]) { new pMsg[74], pID, Money; if(sscanf(params, "ui", pID, Money)) return SendClientMessage(playerid, 0xFFFFFFAA, "{FF6600}Use: {FFFFFF}/givecash [playerid/Name-ID] [Money]"); { GivePlayerMoney(pID, Money); format(pMsg, 74, "{8B8989}INFO: {FFFFFF}%s has gave you $%i.", GetName(playerid), Money); SendClientMessage(pID, 0xFFFFFFAA, pMsg); format(pMsg, 74, "{8B8989}INFO: {FFFFFF}You gave $%i to player %s.", Money, GetName(pID)); SendClientMessage(playerid, 0xFFFFFFAA, pMsg); } return true; }
stock GetName(playerid) { new pName[24]; GetPlayerName(playerid, pName, 24); return pName; }
|
Or he could just use strcmp ...xD
Re: /givecash [playername] [money] -
black_dota - 12.05.2011
Strcmp is slower than zcmd, it is more complicated, and there is much more reasons why to use zcmd and sscanf
It is more optimized and faster, and it is easy to create a commands with zcmd and sscanf.
Re: /givecash [playername] [money] -
SamyRomafia - 12.05.2011
Quote:
Originally Posted by black_dota
You will need sscanf and zcmd
pawn Код:
CMD:givecash(playerid, params[]) { new pMsg[74], pID, Money; if(sscanf(params, "ui", pID, Money)) return SendClientMessage(playerid, 0xFFFFFFAA, "{FF6600}Use: {FFFFFF}/givecash [playerid/Name-ID] [Money]"); { GivePlayerMoney(pID, Money); format(pMsg, 74, "{8B8989}INFO: {FFFFFF}%s has gave you $%i.", GetName(playerid), Money); SendClientMessage(pID, 0xFFFFFFAA, pMsg); format(pMsg, 74, "{8B8989}INFO: {FFFFFF}You gave $%i to player %s.", Money, GetName(pID)); SendClientMessage(playerid, 0xFFFFFFAA, pMsg); } return true; }
stock GetName(playerid) { new pName[24]; GetPlayerName(playerid, pName, 24); return pName; }
|
This bugged...
This dont leave a money at player
Re: /givecash [playername] [money] -
Laronic - 12.05.2011
pawn Код:
//sscanf and zcmd, download links in my signature
COMMAND:givecash(playerid, params[])
{
new targetid, amount;
if(sscanf(params, "ui", targetid, amount)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /givecash [playerid | name] [amount]");
else if(IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFAA, "That player is not connected");
{
new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
new string[45];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerName(targetid, targetname, sizeof(targetname));
GivePlayerMoney(playerid, -amount);
GivePlayerMoney(targetid, amount);
format(string, sizeof(string), "%s gave you $%i.", playername, amount);
SendClientMessage(targetid, 0xFFFFFFAA, string);
format(string, sizeof(string), "You gave %s $%i.", targetname, amount);
SendClientMessage(playerid, 0xFFFFFFAA, string);
}
return 1;
}
Re: /givecash [playername] [money] -
Mean - 12.05.2011
Quote:
Originally Posted by SkizzoTrick
Or he could just use strcmp ...xD
|
WHAT DID YOU JUST SAY?!?
It's slow, it's complicated, it's outdated, there is no reason to use it anymore for commands. In short: it sux.
I'd never expect you to say that o_O...
Re: /givecash [playername] [money] -
jonnyboy - 12.05.2011
Quote:
Originally Posted by Mean
WHAT DID YOU JUST SAY?!?
It's slow, it's complicated, it's outdated, there is no reason to use it anymore for commands. In short: it sux.
I'd never expect you to say that o_O...
|
lol i use it. and its really easy. and for me its not slow. and i only use strcmp and dcmd. the sad thing is that i can't have zcmd and dcmd on the same gamemode D:
Re: /givecash [playername] [money] -
Vvolk - 12.05.2011
Sorry but I need /givecash [playername (ONLY playername)] [amount]. Please someone give me this fucking code, because I need it and I will be very grateful to you