SA-MP Forums Archive
Why commands dont work? - 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)
+--- Thread: Why commands dont work? (/showthread.php?tid=574711)



Why commands dont work? - dundolina - 19.05.2015

Hello, why this commands dont work and give me that i'm not in the place to use them? I'm the right place..

Код:
       if (strcmp("/buyrod", cmdtext, true, 10) == 0)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2, 387.8272,-1870.7032,7.8359) && GetPlayerMoney(playerid) >= 400)
                {
                        if(FRod[playerid] == 0)
                        {
                        FRod[playerid] = 1;
                    SendClientMessage(playerid,0xFFFFFFFF, "Fishing Rod {88AA88}Bought!");
                    SendClientMessage(playerid,0xFFFFFFFF, "/TakeRod to Take it out!");
                    GivePlayerMoney(playerid,-400);
                    }
                    else
                        {
                        SendClientMessage(playerid,0xCD0000FF, "You already got Fishing Rod, you may /takerod !");
                        SendClientMessage(playerid,0xCD0000FF, "Or mabye you don't have enough cash to buy it !");
                        }
                    return 1;
                }
                return SendClientMessage(playerid,0xCD0000FF, "You are not around Fish Market !");
        }
        if (strcmp("/buybait", cmdtext, true, 10) == 0)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2, 387.8272,-1870.7032,7.8359) && GetPlayerMoney(playerid) >= 250)
                {
                        if(Bait[playerid] == 0)
                        {
                        Bait[playerid] = 1;
                    SendClientMessage(playerid,0xFFFFFFFF, " Mixed Baits {88AA88}Bought!");
                    GivePlayerMoney(playerid,-250);
                    }
                    else
                        {
                        SendClientMessage(playerid,0xCD0000FF, "You already got Mixed Baits left!");
                        SendClientMessage(playerid,0xCD0000FF, "Or mabye you don't have enough cash to buy it!");
                        }
                    return 1;
                }
                return SendClientMessage(playerid,0xCD0000FF, "You are not around Fish Market !");
        }
        if (strcmp("/buyline", cmdtext, true, 10) == 0)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2, 387.8272,-1870.7032,7.8359) && GetPlayerMoney(playerid) >= 400)
                {
                        if(FLine[playerid] == 0)
                        {
                        FLine[playerid] = 10;
                    SendClientMessage(playerid,0xFFFFFFFF, "Fishing Line {88AA88}Bought!");
                    GivePlayerMoney(playerid,-400);
                        }
                    else
                        {
                        SendClientMessage(playerid,0xCD0000FF, "You already got Fishing Lines !");
                        }
                    return 1;
                }
                return SendClientMessage(playerid,0xCD0000FF, "You are not around Fish Market !");
        }



Re: Why commands dont work? - Konstantinos - 19.05.2015

Check if the player is in range only because even if they are and they do not have enough money, it will display that you are not near that place.


Re: Why commands dont work? - dundolina - 19.05.2015

You're correct. Thanks for everythings, the problem is the money - how stupid..


Re: Why commands dont work? - PowerPC603 - 19.05.2015

PHP код:
if (strcmp("/buyrod"cmdtexttrue10) == 0)
{
    
// If the player already has a fishing rod, inform the player and exit the command
    
if (FRod[playerid] == 1)
        return 
SendClientMessage(playerid,0xCD0000FF"You already got Fishing Rod, you may /takerod !");
    
// If the player isn't near a fish market, inform him and exit the command
    
if (!IsPlayerInRangeOfPoint(playerid2387.8272,-1870.7032,7.8359))
        return 
SendClientMessage(playerid,0xCD0000FF"You are not around Fish Market !");
    
// If the player doesn't have enough money to buy a fishing rod, inform him and exit the command
    
if (GetPlayerMoney(playerid) < 400)
        return 
SendClientMessage(playerid,0xCD0000FF"You don't have enough money to buy a fishing rod");
    
// When the player doesn't have a fishing rod yet, is near a fishing market and has enough money, let him buy a fishing rod
    
FRod[playerid] = 1;
    
SendClientMessage(playerid,0xFFFFFFFF"Fishing Rod {88AA88}Bought!");
    
SendClientMessage(playerid,0xFFFFFFFF"/TakeRod to Take it out!");
    
GivePlayerMoney(playerid,-400);

I re-structured your commands a bit, but your mistake was not using "else" for the message "You are not around Fish Market !".
That SendClientMessage was always executed, even if you were in range and even if you had enough money to buy one.


Re: Why commands dont work? - dundolina - 19.05.2015

I dont know why this dont work, can anyone give me another way?


Re: Why commands dont work? - tooMuch - 19.05.2015

So what's not working now?


Re: Why commands dont work? - dundolina - 19.05.2015

Dont give me any of these messages.


Re: Why commands dont work? - tooMuch - 19.05.2015

What? U said problem was in money, and after that u asked help again so what's the problem, errors?


Re: Why commands dont work? - dundolina - 19.05.2015

Yeah but i want to send me a message when i dont have money, another message when i have rod and etc.


Re: Why commands dont work? - tooMuch - 19.05.2015

But there's already done
Quote:

SendClientMessage(playerid,0xCD0000FF, "Or mabye you don't have enough cash to buy it !");