[FilterScript] [FS] Drug Inventory [Saving Done!] [Added Drug Pickup]
#1

Drug Inventory
First of all I wasnt even sure to release that small script, actually it's almost a useful snippet tho...

Nevermind, its like most drug systems, you have weed heroine and cigars, drugs change your weather and you can open a drug bank!

Commands;

/buydrugs (IsPlayerInRangeOfPoint commented out and gives you drugs for $100)
/use weed (Fills your health)
/use heroine (Fills armour)
/drugbankopen [Pass] (Open a drug bank account)
/drugbanklogin [Pass] (Get your drugs at bank - if you didnt open a bank you will lose drugs after disconnect)
/inventory (Shows drugs you have ATM)

Also added a pickup near Crack Den (SP Mission) that gives you min 1 manx 3 weed (Changeable)

Now saves heroine and weed!!! (removed cigars but can script it again)

Dont flame at me saying "You call it a FS, I can script it with my a**!!!"

Link
Pastebin
Bugs-
Unbelievable amounts of Loose indentention!
Reply
#2

great work useful for rp's, nice.
Reply
#3

useful fs (:

thanks.
Reply
#4

It is very simple, will make /growweed for that
Reply
#5

Unfortunately it doesnt save
Reply
#6

Saving system down, just giving out undone now, I cant save 3 vars and read them as Weed[playerid] Heroine[playerid] and Cigars[playerid], sorry but file functions cant do that, you can edit it with Dini if you want tho....

pawn Код:
#include <a_samp>

new Weed[MAX_PLAYERS];
new Heroine[MAX_PLAYERS];
new Cigars[MAX_PLAYERS];

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Simple Drug System by Evrim - Loaded");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" Simple Drug System by Evrim - Unloaded");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    new File:Drugfile;
    new PName[24];
    GetPlayerName(playerid, PName, sizeof(PName));
    new FName[32];
    format(FName, sizeof(FName), "%s.txt", PName);
    if(!fexist(FName)) Drugfile = fopen(FName, io_readwrite);
    else if(fexist(FName)) Drugfile = fopen(FName, io_append);
    fclose(Drugfile);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new File:Drugfile;
    new string[128];
    new PName[24];
    GetPlayerName(playerid, PName, sizeof(PName));
    new FName[32];
    format(FName, sizeof(FName), "%s.txt", PName);
    Drugfile = fopen(FName, io_append);
    fclose(Drugfile);
    fremove(FName);
    Drugfile = fopen(FName, io_readwrite);
    format(string, sizeof(string),"%d Weed, %d Heroine and %d Cigarettes", Weed[playerid], Heroine[playerid], Cigars[playerid]);
    fwrite(Drugfile, string);
    fclose(Drugfile);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/inventory", cmdtext, true, 10) == 0)
    {
        new File:Drugfile;
        new string[128];
        new string2[128];
        new PName[24];
        GetPlayerName(playerid, PName, sizeof(PName));
        new FName[32];
        format(FName, sizeof(FName), "%s.txt", PName);
        Drugfile = fopen(FName, io_append);
        fread(Drugfile, string);
        fclose(Drugfile);
        format(string2, sizeof(string2), "You got %s", string);
      new inventorystr1[128];
        format(inventorystr1, sizeof(inventorystr1),string,Weed[playerid]);
        SendClientMessage(playerid, 0x881111AA, "_________Inventory_________");
        SendClientMessage(playerid, 0x881111AA, string2);
        SendClientMessage(playerid, 0x881111AA, "____/buydrugs to buy more____");
        return 1;
    }
    if (strcmp("/use weed", cmdtext, true, 10) == 0)
    {
      if (Weed[playerid] >= 0)
      {
        Weed[playerid] = Weed[playerid] - 1;
        SendClientMessage(playerid,0x107010AA,"You smoked some weed");
        SetPlayerHealth(playerid, 100.0);
        SetPlayerWeather(playerid, -66);
        SetTimer("NormalWeather",30000,false);
            return 1;
      }
      else
      {
        SendClientMessage(playerid,0x991010AA,"You don't have any weed");
            return 1;
      }
    }
    if (strcmp("/use heroine", cmdtext, true, 10) == 0)
    {
      if (Heroine[playerid] >= 0)
      {
        Heroine[playerid] = Heroine[playerid] - 1;
        SendClientMessage(playerid,0x107010AA,"You used some heroine");
        SetPlayerArmour(playerid, 100.0);
        SetPlayerWeather(playerid, -66);
        SetTimer("NormalWeather",30000,false);
            return 1;
      }
      else
      {
        SendClientMessage(playerid,0x991010AA,"You don't have any heroine");
            return 1;
      }
    }
    if (strcmp("/buydrugs", cmdtext, true, 10) == 0)
    {
      if (GetPlayerMoney(playerid) >= 100)
      {
        //if (IsPlayerInRangeOfPoint(playerid, 7.0, 0.0, 0.0, 0.0) == 1) { //Change or comment out
        GivePlayerMoney(playerid, -100);
        SendClientMessage(playerid,0x107010AA,"You bought some drugs - $100");
        Heroine[playerid] = Heroine[playerid] + 2;
        Weed[playerid] = Weed[playerid] + 3;
        Cigars[playerid] = Cigars[playerid] + 2;
        //} //Comment out too if you use
            return 1;
      }
      else
      {
        SendClientMessage(playerid,0x991010AA,"You don't have enough money - $100");
            return 1;
      }
    }
    if (strcmp("/smoke", cmdtext, true, 10) == 0)
    {
      if (Cigars[playerid] >= 0)
      {
        Cigars[playerid] = Cigars[playerid] - 1;
        SendClientMessage(playerid,0x107010AA,"You lit a cigarette");
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
            return 1;
      }
      else
      {
        SendClientMessage(playerid,0x991010AA,"You don't have any cigarettes");
            return 1;
      }
    }
    return 0;
}

forward NormalWeather();
public NormalWeather()
{
    SetWeather(11); //Change it to your GM weather!!!
}
Sorry, if I created a file for every was your scriptfiles folder would be total spammed, this version saves only a string says what you had when you last leave...
Reply
#7

And if someone can teach me Dini I can make it maybe (Never learned Dini, only thing I cant learn!) and if you make it a Dini version on your own please give credits
Reply
#8

Quote:
Originally Posted by Thrarod
And if someone can teach me Dini I can make it maybe (Never learned Dini, only thing I cant learn!)
http://forum.sa-mp.com/index.php?topic=126584.0
http://forum.sa-mp.com/index.php?topic=161905.0
Reply
#9

This is nice , could improve though.
Reply
#10

I said I cant learn from tuts' need someone to tell me!


-Yeah Its nice but doesnt save, only problem - I tried one and failed cus fread sux
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)