Saving vehicle status on gamemodeexit
#1

Linkvehicletointerior
Setvehiclevirtualworld.

Hi, please can someone create an actual working code from the one I have done below:

Ongamemodeinit
{
LoadVehicleInteriors();
LoadVehicleVirtualWorlds();
}


Public LoadVehicleInteriors(); // this is where I need help.
{
Getvehicleinteriors(I);
SaveVehicleInteriors(I); // how an I save them using dini or something like that?
Getvehiclevirtualworld(I);
Savevehiclevirtualworlds(I);
}

Thanks.
Reply
#2

Okay, i have started to make the script. Here it is:

pawn Code:
new carworld;


if(strcmp(cmd, "/park", true) == 0)
    {

                new currentcar;
                currentcar = GetPlayerVehicleID(playerid);
                carworld = GetVehicleVirtualWorld(currentcar);

                if (!dini_Exists(carintvw(playerid)))
                {
                    dini_Create(carintvw(playerid));
                }

                SaveStats(playerid);
        }
        return 1;
    }

forward LoadVWandInt(playerid);
public LoadVWandInt(playerid)
{
    SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), carworld);
    KillTimer(Loadcarintandwv);
    return 1;
}

Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}

carintvw(playerid)
{
  new a[256]; format(a, sizeof(a), "/ParkedVehicles/%s.ini",udb_encode(Player(playerid)));
  return a;
}

SaveStats(playerid)
{
  dini_IntSet(carintvw(playerid), "carworld", carworld);
  //dini_IntSet(carintvw(playerid), "PositionY", floatround(positiony));
  //dini_IntSet(carintvw(playerid), "PositionZ", floatround(positionz));
}

LoadStats(playerid)
{
  carworld = dini_Int(carintvw(playerid), "carworld");
  //positiony = dini_Int(carintvw(playerid), "PositionY");
  //positionz = dini_Int(carintvw(playerid), "PositionZ");
}
But there is an error on this line:

pawn Code:
carintvw(playerid)
{
  new a[256]; format(a, sizeof(a), "/ParkedVehicles/%s.ini",udb_encode(Player(playerid))); // This line
  return a;
}
ERROR: Undefined symbol udb_encode
How can i fix it?
Reply
#3

Quote:
Originally Posted by lewismichaelbbc
View Post
Okay, i have started to make the script. Here it is:

ERROR: Undefined symbol udb_encode
How can i fix it?
Download the udb include
Reply
#4

Okay, i have got the include, and it compiled perfectly. But, when i type the command to park, it sends the player a message it has been parked. - When i disconnect and connect, the vehicle is not in the correct virtualworld as i parked it in.

here is my script:
http://pastebin.com/qHixXpRx

Or see it here:

pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript

#include <a_samp>
#include <Dini>
#include <dudb>

#define COLOUR_PM           0xFFFF2AFF
new carworld;
new Loadcarvw;
forward LoadcarVW(playerid);

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
   
    Loadcarvw = SetTimer("LoadcarVW", 5000, 0);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    LoadStats(playerid);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/parkinvirtualworld", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new currentcar;
            currentcar = GetPlayerVehicleID(playerid);
            carworld = GetVehicleVirtualWorld(currentcar);
            if (!dini_Exists(carintvw(playerid)))
            {
                dini_Create(carintvw(playerid));
            }
            SaveStats(playerid);
            SendClientMessage(playerid, COLOUR_PM, "You have parked your car in a virtual world");
        }
        return 1;
    }
    if(strcmp(cmdtext, "/setvw10", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), 10);
            SetPlayerVirtualWorld(playerid, 10);
        }
        return 1;
    }
    return 0;
}

forward LoadcarVW(playerid);
public LoadcarVW(playerid)
{
    SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), carworld);
    KillTimer(Loadcarvw);
    return 1;
}

Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}

carintvw(playerid)
{
  new a[256]; format(a, sizeof(a), "/ParkedVehicles/%s.ini",udb_encode(Player(playerid)));
  return a;
}

SaveStats(playerid)
{
  dini_IntSet(carintvw(playerid), "carworld", carworld);
  //dini_IntSet(carintvw(playerid), "PositionY", floatround(positiony));
  //dini_IntSet(carintvw(playerid), "PositionZ", floatround(positionz));
}

LoadStats(playerid)
{
    carworld = dini_Int(carintvw(playerid), "carworld");
  //positiony = dini_Int(carintvw(playerid), "PositionY");
  //positionz = dini_Int(carintvw(playerid), "PositionZ");
}
I just looked in My scriptfiles folder: /ParkedVehicles/ and it has saved the ID of the virtualworld.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)