wut? -
saffierr - 17.07.2014
I am already done, but again I miss 1 thing: EXAMPLE: when I have $0 IG, and I type /givecash 0 1, ($1dollar), It says "You shared you're money" While I have $0??
PHP код:
CMD:givecash(playerid, params[])
{
new id, money;
if(sscanf(params, "u", id, money)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /givecash [ID] [amount]");
else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid playerid.");
GivePlayerMoney(GetPlayerMoney(playerid, money),(playerid, money));
SendClientMessage(playerid, COLOR_YELLOW, "You shared you're money!");
return 1;
}
Re: wut? -
Dignity - 17.07.2014
pawn Код:
if(sscanf(params, "u", id, money))
You specified two params yet use only one specifier.
This will work:
pawn Код:
if(sscanf(params, "ui", id, money))
Re: wut? -
Battlezone - 17.07.2014
This is the correct form
pawn Код:
CMD:givecash(playerid, params[])
{
new id, money;
if(sscanf(params, "ui", id, money)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /givecash [ID] [amount]");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid playerid.");
if(GetPlayerMoney(playerid) < money) return SendClientMessage(playerid, COLOR_RED, "No enough cash");
GivePlayerMoney(GetPlayerMoney(playerid, money),(playerid, money));
SendClientMessage(playerid, COLOR_YELLOW, "You shared you're money!");
return 1;
}
Re: wut? -
saffierr - 17.07.2014
Thanks both, But why "ui"? and not "u"?
"ui" is user+integer ?? if yes, why both?
AND, please how to add, SendClientMessage(playerid, COLOR_RED, "You can't share with yourself!"); ?
Re: wut? -
Dignity - 17.07.2014
"ui" is user + integer, and you need multiple specifiers for multiple params. You need to specify what type a param is for it to extract the data properly.
Not sure if I made any sense, but that's pretty much what it comes down to I think.
By the way, you might want to read this:
https://github.com/Y-Less/sscanf/wik...nners-Tutorial as it would've saved you the time it took you to create these threads.
To disallow players from giving money to themself, use this (as Battlezone already stated):
pawn Код:
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "You can't share with yourself!");
Re: wut? -
Battlezone - 17.07.2014
I'm afraid you got a small mistake,
pawn Код:
if (id == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't share with yourself!");
to prevent a player from sharing money with himself
Re: wut? -
saffierr - 17.07.2014
Yep, It's fixed now thank you both, for trying me to help. I both +repped.
Re: wut? -
admiralspeedy - 17.07.2014
I'm guessing by the number of threads you have posted, you're goal is to have the community write your script for you?
The SA-MP wiki has a ton of info that you could use instead of asking everyone to fix all of your bugs.
Re: wut? -
saffierr - 17.07.2014
SA-MP wiki is an alternative, I use this for my problems. communicate with people is much easier. Comprende?
and btw, I am not even busy to make a own gm script. I am just doing random things to learn.
after I have enough knowledge I script my own gm.