Basic saving
#1

I would like to know how to save a basic file:

/DMV = saves DMV= 1 in a file and when a player connect it has 1

if not a normal player has DMV=0

BUT HOW?!?!
Reply
#2

First put this in your pawno includes, it's dini file functions which you'll be using.
http://dracoblue.net/download-release/35/dini_1_6.zip

Put this on the top of your script under includes.
PHP код:
new DMV[MAX_PLAYERS]; // We will use this to set every single player's DMV to 1 or 0 according to the file 
Now you have to make the command, put this under OnPlayerCommandText
PHP код:
if (strcmp("/dmv"cmdtexttrue4) == 0// The command
{
    if(!
dini_Exists("dmv.cfg"dini_Create("dmv.cfg"// If the file is not in your scriptfiles folder the script will create it
    
if(dini_Int("dmv.cfg""dmv") == 0// if dmv in the file is = 0
    
{
        
dini_IntSet("dmv.cfg""dmv""1"); // Set dmv=1 in the file
        
SendClientMessage(playerid0xFFFFFFFF"You have set DMV to 1.");
    }
    else if(
dini_Int("dmv.cfg""dmv") == 1// if dmv in the file is = 1
    
{
        
dini_IntSet("dmv.cfg""dmv""0"); // Set dmv=0 in the file
        
SendClientMessage(playerid0xFFFFFFFF"You have set DMV to 0.");
    }
    for(new 
i=0i<MAX_PLAYERSi++) // loop to set connected players DMV to the value from file
    
{
        if(
IsPlayerConnected(i))
        {
            
DMV[i] = dini_Int("dmv.cfg""dmv");
        }
    }
    return 
1;

Put this under OnPlayerConnect
PHP код:
DMV[playerid] = dini_Int("dmv.cfg""dmv"); // Set the player's DMV to the value in file
if(dini_Int("dmv.cfg""dmv") == 0// if dmv in the file is = 0
{
    
SendClientMessage(playerid0xFFFFFFFF"Your DMV is 1.");
}
else if(
dini_Int("dmv.cfg""dmv") == 1// if dmv in the file is = 1
{
    
SendClientMessage(playerid0xFFFFFFFF"Your DMV is 1.");

If you get any error on compiling tell me, written it directly into the browser.
Reply
#3

Thanks! But i got some errors:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/buylicense", cmdtext, true, 4) == 0) // The command
{
    if(!dini_Exists("dmv.cfg") dini_Create("dmv.cfg") // If the file is not in your scriptfiles folder the script will create it
    if(dini_Int("dmv.cfg", "dmv") == 0) // if dmv in the file is = 0
    {
        dini_IntSet("dmv.cfg", "dmv", "1"); // Set dmv=1 in the file
        SendClientMessage(playerid, -1, "(INFO) You bought a legal driving license.");
        GivePlayerMoney(playerid, -1000);
    }
    else if(dini_Int("dmv.cfg", "dmv") == 1) // if dmv in the file is = 1
    {
        dini_IntSet("dmv.cfg", "dmv", "1"); // Set dmv=0 in the file
        SendClientMessage(playerid, 0xFFFFFFFF, "(INFO) You already have a driving license.");
    }
    for(new i=0; i<MAX_PLAYERS; i++) // loop to set connected players DMV to the value from file
    {
        if(IsPlayerConnected(i))
        {
            DMV[i] = dini_Int("dmv.cfg", "dmv");
        }
    }
    return 1;
}
    return 0;
}

Quote:

C:\Users\Luca\Desktop\dmvlicense.pwn(95) : error 001: expected token: ")", but found "-identifier-"
C:\Users\Luca\Desktop\dmvlicense.pwn(96) : error 001: expected token: ";", but found "if"
C:\Users\Luca\Desktop\dmvlicense.pwn(9 : error 035: argument type mismatch (argument 3)
C:\Users\Luca\Desktop\dmvlicense.pwn(104) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#4

O.o i didn't understand anything :P But thanks:

I would: /dmv = DMV=1 and saves it

if someone DOESN'T type /dmv it remains DMV=0

A basic driving license system
Reply
#5

Anyone? please, srry for bump
Reply
#6

One of the things that i hate about scripting is: timers and saving :P so i just would make BASIC system

New player = DMV=0
if i type /dmv it saves to DMV=1
Reply
#7

I didn't understand the part of Login/Register -.- what's the funcion of it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)