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...