How can i make this save?
#1

Ok i need /stealfuel to be able to steal a random ammount of fuel and save it,Then thay can spend fuel to buy things etc.

i have checkpoints and /stealfuel has a timer i just need the fuel ammounts/saving done IDK how to start with it

heres the codes
Код:


#define STEAL_FUEL 0

forward steal(playerid);

new bool:stealfuel[MAX_PLAYERS];
new bool:canstealfuel[MAX_PLAYERS];
new bool:waitstealfuel[MAX_PLAYERS];


public OnGameModeInit()
{
    CreateCheckpoint(GLOBAL_OWNER_ID, STEAL_FUEL, 1940.3191,1017.8076,992.4688, 2.4);
    StartCheckpointSeeking();
    return 1;
}
public OnPlayerConnect(playerid)
{
        canstealfuel[playerid] = false;
        return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext,"/stealfuel",true))
        {
        if(waitstealfuel[playerid] == true)
		{
		SendClientMessage(playerid, RED, "[ATT]:Wait Before Stealing Fuel Again!");
		}
		else if(canstealfuel[playerid] == true)
  		{
		    if(stealfuel[playerid] == false)
			{
				SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
				GameTextForPlayer(playerid, "~w~Stealing Fuel ~r~Please Wait!",10000,5);
				SendClientMessage(playerid, RED, "[ATT]:You Are Stealing Fuel! Don't Exit The Checkpoint!");
				timer1 = SetTimerEx("fuel", 10000, false, "d", playerid);
				stealfuel[playerid] = true;
			}
			else
			{
			SendClientMessage(playerid, RED, "[ATT]:You Are Already Stealing Fuel!");
			}
		}
		else
		{
		SendClientMessage(playerid, RED, "[ATT]:You Need To Be In The Checkpoint To Steal Fuel!");
		}
		return 1;
	    }
            return 0;
}
public OnPlayerLeaveCheckpoint(playerid)
{
    VerifyCheckpointe(playerid);
	return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
	VerifyCheckpoint(playerid);
	return 1;
}
public OnCheckpointEXIT(playerid, checkpointid)
{
	switch(checkpointid)
	{
		case STEAL_FUEL:
	   	{
	  		if(canstealfuel[playerid] == true)
	    	{
				canstealfuel[playerid] = false;
				if(stealfuel[playerid] == true)
				{
					stealfuel[playerid] = false;
					GameTextForPlayer(playerid, "~r~You Left The Checkpoint! No Fuel Stole'n!",4000,5);
					SendClientMessage(playerid, RED, "[ATT]:You Left The Checkpoint! No Fuel Stole'n!");
					KillTimer(timer1);
				}
			}
		}
	}
	return 1;
}
public OnCheckpointEnter(playerid, checkpointid)
{
	switch(checkpointid)
	{
		case STEAL_FUEL:
		{
	 		canstealfuel[playerid] = true;
	 		{
	 		    GameTextForPlayer(playerid, "~r~/stealfuel",4000,5);
				SendClientMessage(playerid, RED, "[ATT]:Type /stealfuel To Start Stealing There Fuel!");
	 		}
	 	}
	}
	return 1;
}
I need these to be able to steal random ammouuts of fuel and save it,Also a /fuel to see your fuel,And must be able to trade/buy with fuel with other players.

The codes work fine with a timer between each steal

Please help i have no idea were to start :S
Reply
#2

I don't have much time: I'll go on holiday.
But I say: Use "Dini"
You can use that to save all the info you want. Here's a little example:

pawn Код:
//SAVE A STRING INTO A FILE

if(!dini_Exists("FILE.txt")) dini_Create("FILE.txt");
dini_IntSet("FILE.txt", "LineID", "1"); //To set an INT. For example, in the file 'file.txt' is now this line: "LineID=1"
dini_Set("FILE.txt", "Something", "A string"); //To set an STRING.
dini_FloatSet("FILE.txt", "PosX", "0.00000"); //To set an FLOAT
dini_BoolSet("FILE.txt", "Opened", "true"); //To set an BOOL
//You can use string of course ;)
To read from the file:

pawn Код:
if(!dini_Exists("FILE.txt")) return 0;
a_int = dini_Int("FILE.txt", "LineID"); //To get an INT.
a_string = dini_Get("FILE.txt", "Something"); //Wrong. Sorry. Use 'strins'
a_float = dini_Float("FILE.txt", "PosX");
a_bool = dini_Bool("FILE.txt", "Opened") ? true : false;
This is just an example to use it.
And here's the DINI include: http://dracoblue.net/download-release/35/dini_1_6.zip

I hope this helped you

Kind Regards,
Kwarde
Reply
#3

I dont understand this...can someone explain to me in nub?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)