Command not working! - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command not working! (
/showthread.php?tid=85081)
Command not working! -
cigo - 05.07.2009
Код:
if (strcmp(cmdtext, "/buyaccess", true) == 0)
{
if (GetPlayerMoney(playerid) >= 10000000)
{
SendClientMessage(playerid, 0x33AA33AA, "You just bought access to weapon store!");
gGunAccess[playerid] += 1;
SetPlayerMoney(playerid, gPlayerMoney[playerid] - 10000000);
return 1;
}
if(GetPlayerMoney(playerid) < 1000000)
{
return SendClientMessage(playerid, 0xAA3333AA, "You have not enough money!");
}
return 1;
}
whats wrong with this command? when i type it nothing happens... ;(
Re: Command not working! -
Grim_ - 05.07.2009
Is your OnPlayerCommandText returning 0?
Re: Command not working! -
Ignas1337 - 05.07.2009
I've got a question, what happens when either return is 0 or 1 onplayercommandtext? I dun get it..
Re: Command not working! -
refshal - 05.07.2009
Quote:
Originally Posted by Izanagi
I've got a question, what happens when either return is 0 or 1 onplayercommandtext? I dun get it..
|
If you don't return 0, then your command won't work.
Re: Command not working! -
cigo - 05.07.2009
Quote:
Originally Posted by Swift_
Is your OnPlayerCommandText returning 0?
|
Yes!
Re: Command not working! -
cigo - 05.07.2009
someone?
Re: Command not working! -
Nero_3D - 05.07.2009
Its not important if the commandtext return 0, 1 or any other value!
The problem you had you checked if the player have 10'000'000 money and if he have less than 1'000'000, also if you have something between 1'000'000 and 10'000'000 money, you wont get any message
That maybe happend because the numbers are unreadable if they arent grouped
You could have used else, with that you wouldnt have had this problem
pawn Код:
if (strcmp(cmdtext, "/buyaccess", true) == 0)
{
if (GetPlayerMoney(playerid) >= 10_000_000)
{ //with that is the number better readable, pawn supports this (source: pawn-lang.pdf)
SendClientMessage(playerid, 0x33AA33AA, "You just bought access to weapon store!");
SetPlayerMoney(playerid, gPlayerMoney[playerid] - 10000000);
gGunAccess[playerid] += 1;
}
else SendClientMessage(playerid, 0xAA3333AA, "You have not enough money!");
return true;
}
Re: Command not working! -
Ignas1337 - 05.07.2009
Quote:
Originally Posted by ♣ ⓐⓢⓢ
Its not important if the commandtext return 0, 1 or any other value!
The problem you had you checked if the player have 10'000'000 money and if he have less than 1'000'000, also if you have something between 1'000'000 and 10'000'000 money, you wont get any message
That maybe happend because the numbers are unreadable if they arent grouped
You could have used else, with that you wouldnt have had this problem
pawn Код:
if (strcmp(cmdtext, "/buyaccess", true) == 0) { if (GetPlayerMoney(playerid) >= 10_000_000) { //with that is the number better readable, pawn supports this (source: pawn-lang.pdf) SendClientMessage(playerid, 0x33AA33AA, "You just bought access to weapon store!"); SetPlayerMoney(playerid, gPlayerMoney[playerid] - 10000000); gGunAccess[playerid] += 1; } else SendClientMessage(playerid, 0xAA3333AA, "You have not enough money!"); return true; }
|
I like the way you handle large integers. Thanks for showing us, people who didn't read ALL pawn-lang.pdf, this way. It sure helps out at certain points ;]