A little help please.
#1

I already have an idea of how "scripting" works, I just need someone to help me out here.
Ok so, just help me out here.

/Buyweed - How does this work, I understand it kind of works like this but I don't know how to write the lines. If player money < 300 then send message "You don't have the money, it's $300 per gram!" but if not then playerweed++.

/Smokeweed - If player weed < 1 then "You don't have weed to smoke!" but if not then playerweed-- send message "You smoked a gram of weed!" Set player health 100.

Can someone just make these things into lines for me and tell me where to put em?
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/buyweed", cmdtext, true))
    {
        if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid, 0xF60000AA, "You do not have $300 for the weed!");
        SetPVarInt(playerid, "Weed", GetPVarInt(playerid, "Weed") + 1);
        GivePlayerMoney(playerid, -300);
        SendClientMessage(playerid, 0x0000F6AA, "You buy some weed!");
        return 1;
    }
    if(!strcmp("/Smokeweed", cmdtext, true))
    {
        if(GetPVarInt(playerid, "Weed") == 0) return SendClientMessage(playerid, 0xF60000AA, "You don't have any weed!");
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid, 0x0000F6AA, "You smoke some weed!");
        SetPVarInt(playerid, "Weed", GetPVarInt(playerid, "Weed") - 1);
        return 1;
    }
    return 0;
}
Reply
#3

pawn Код:
#define WeedPricePerGram 300
new WeedGrams[MAX_PLAYERS]; (Or use GetMaxPlayers()?)

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Buyweed", cmdtext, true, 10) == 0)
        {
        new money=GetPlayerMoney(playerid);
        if(money<WeedPricePerGram)
        {
            SendClientMessage(playerid,0xFF0000FF/*Red*/,"You don't have the money, it's $300 per gram!");
        }
        else
        {
            SetPlayerMoney(playerid,GetPlayerMoney(playerid)-WeedPricePerGram);
            WeedGrams[playerid]++;
        }
                return 1;
    }
    if (strcmp("/Smokeweed", cmdtext, true, 10) == 0)
        {
                if(WeedGrams<1)
                {
                        SendClientMessage(playerid,0xFF0000FF/*Red*/,"You don't have weed to smoke!");
                }
                else
                {
            SendClientMessage(playerid,0xFF0000FF/*Red*/,"You don't have weed to smoke!");
                        SetPlayerHealth(playerid);
            WeedGrams--;
                }
                return 1;
        }
}
Kind'a like this, but instead of game money you should use an variable, otherwise it can be hacked easy.
FCK. I was too slow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)