textdraw with shop failure
#1

hi i made shop with easy textdraw, i use the command the textdraw show but i wont get the thing i try to buy,

example if i do /shopmenu

the textdraw comes up

#1 health
#2 armor

etc

when i type 1 it sends it to the chat i dont get health..

this what i got

in the command /shopmenu

pawn Код:
Shop[playerid] = 1;
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(Shop[playerid] == 1)
    {
        if(text[0] == '1')
        {
            if(armor[playerid] == 1)
            {
                SendClientMessage(playerid, COLOR_RED, "You can Only heal One Time Each spawn.");
                Shop[playerid] = 0;
            }
Reply
#2

You have to show us the full code

Just Debug it...and look if it gets called..and then what if conditions there could be..so that the code get stuck
Reply
#3

pawn Код:
CMD:shopmenu(playerid, params[])
{
    #pragma unused params
    if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You cant Use This Cmd when Dead.");
    if(IsPlayerConnected(playerid))
    {
        RemoveAllTextDraws(playerid);
        TextDrawShowForPlayer(playerid, ShopTD0);
        TextDrawShowForPlayer(playerid, ShopTD1);
        TextDrawShowForPlayer(playerid, ShopTD2);
        TextDrawShowForPlayer(playerid, ShopTD3);
        TextDrawShowForPlayer(playerid, ShopTD4);
        TextDrawShowForPlayer(playerid, ShopTD5);
        TextDrawShowForPlayer(playerid, ShopTD6);
        TextDrawShowForPlayer(playerid, ShopTD7);
    }
    Shop[playerid] = 1;
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(Shop[playerid] == 1)
    {
        if(text[0] == '1')
        {
            if(ExtraPill[playerid] == 1)
            {
                SendClientMessage(playerid, COLOR_RED, "you may only buy one pill each spawn");
                RemoveAllTextDraws(playerid);
                Shop[playerid] = 0;
            }
            else
            if(ExtraPill[playerid] == 0)
            {
                if(GetPVarInt(playerid, "Pill") == 1) return SendClientMessage(playerid, COLOR_RED, "You have already one pill");
                if(GetPlayerMoney(playerid) <= 25800) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money you need 25800");
                SetPlayerMoney(playerid, GetPlayerMoney(playerid) -25800);
                SetPVarInt(playerid, "Pill", 1);
                ExtraPill[playerid] = 1;
                RemoveAllTextDraws(playerid);
                Shop[playerid] = 0;
            }
    }
            return 0;
    return 1;
}
Reply
#4

Solution

Other then the missing bracket, I don't see why this would not work? I have made the missing bracket bold.
I changed the check to strcmp that should work for you, however you could also use strval.

Код:
CMD:shopmenu(playerid, params[])
{
	#pragma unused params
	if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You cant Use This Cmd when Dead.");
	if(IsPlayerConnected(playerid))
	{
		RemoveAllTextDraws(playerid);
		TextDrawShowForPlayer(playerid, ShopTD0);
		TextDrawShowForPlayer(playerid, ShopTD1);
		TextDrawShowForPlayer(playerid, ShopTD2);
		TextDrawShowForPlayer(playerid, ShopTD3);
		TextDrawShowForPlayer(playerid, ShopTD4);
		TextDrawShowForPlayer(playerid, ShopTD5);
		TextDrawShowForPlayer(playerid, ShopTD6);
		TextDrawShowForPlayer(playerid, ShopTD7);
	}
	
	Shop[playerid] = 1;
	return 1;
}

public OnPlayerText(playerid, text[])
{
	if(Shop[playerid] == 1)
	{
		if( !strcmp( text[0], '1' ) )
		{
			if( ExtraPill[playerid] == 1 )
			{
				SendClientMessage(playerid, COLOR_RED, "you may only buy one pill each spawn");
			}
			else
			{
				if(GetPVarInt(playerid, "Pill") == 1) return SendClientMessage(playerid, COLOR_RED, "You have already one pill");
				if(GetPlayerMoney(playerid) <= 25800) return SendClientMessage(playerid, COLOR_RED, "You dont have enough money you need 25800");
				SetPlayerMoney(playerid, GetPlayerMoney(playerid) -25800);
				SetPVarInt(playerid, "Pill", 1);
				ExtraPill[playerid] = 1;
			}

			Shop[playerid] = 0;
			RemoveAllTextDraws(playerid);
		} // you missed a bracket here
	}

	return 1;
}
Reply
#5

not working man..
Reply
#6

Sorry, I have made a mistake.

It should be double quotes, not single.

Код:
if( !strcmp( text[0], "1" ) )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)