Vehicle system.
#1

Hello all.. Im have a biig problem with car system.. When i buy car, then tune it, and quit the game. - Saves perfectly. But, when i log on, take that saved car, and drive it somewhere, than relog - Car poz set's to first saved poz..

Quote:

stock SaugojamMasina(playerid)
{
new failas[43],ZaidejoVardas[MAX_PLAYER_NAME],Float:mPozicija[3];
new vehicleid = playerDB[playerid][pcar];
GetPlayerName(playerid,ZaidejoVardas,MAX_PLAYER_NA ME);
format(failas,43,"\\saves\\cars\\%s.ini",ZaidejoVa rdas);
if(!dini_Exists(failas)) dini_Create(failas);
dini_IntSet(failas,"Modelis",GetVehicleModel(vehic leid));
GetVehiclePos(vehicleid,mPozicija[0],mPozicija[1],mPozicija[2]);
dini_FloatSet(failas,"X",mPozicija[0]);
dini_FloatSet(failas,"Y",mPozicija[1]);
dini_FloatSet(failas,"Z",mPozicija[2]);
GetVehicleZAngle(vehicleid,mPozicija[0]);
dini_FloatSet(failas,"F",mPozicija[0]);
dini_IntSet(failas,"Degalai",vehicleDB[vehicleid][gas]);
dini_IntSet(failas,"Spalva1",vehicleDB[vehicleid][spalvos][0]);
dini_IntSet(failas,"Spalva2",vehicleDB[vehicleid][spalvos][1]);
dini_IntSet(failas,"Paintjob",vehicleDB[vehicleid][spalvos][2]);
dini_IntSet(failas,"Tune0",GetVehicleComponentInSl ot(vehicleid,0));
dini_IntSet(failas,"Tune1",GetVehicleComponentInSl ot(vehicleid,1));
dini_IntSet(failas,"Tune2",GetVehicleComponentInSl ot(vehicleid,2));
dini_IntSet(failas,"Tune3",GetVehicleComponentInSl ot(vehicleid,3));
dini_IntSet(failas,"Tune4",GetVehicleComponentInSl ot(vehicleid,4));
dini_IntSet(failas,"Tune5",GetVehicleComponentInSl ot(vehicleid,5));
dini_IntSet(failas,"Tune6",GetVehicleComponentInSl ot(vehicleid,6));
dini_IntSet(failas,"Tune7",GetVehicleComponentInSl ot(vehicleid,7));
dini_IntSet(failas,"Tune8",GetVehicleComponentInSl ot(vehicleid,8));
dini_IntSet(failas,"Tune9",GetVehicleComponentInSl ot(vehicleid,9));
dini_IntSet(failas,"Tune10",GetVehicleComponentInS lot(vehicleid,10));
dini_IntSet(failas,"Tune11",GetVehicleComponentInS lot(vehicleid,11));
dini_IntSet(failas,"Tune12",GetVehicleComponentInS lot(vehicleid,12));
dini_IntSet(failas,"Tune13",GetVehicleComponentInS lot(vehicleid,13));
}

stock UzkraunamUzrakintaMasina(playerid)
{
new failas[43],ZaidejoVardas[MAX_PLAYER_NAME];
GetPlayerName(playerid,ZaidejoVardas,MAX_PLAYER_NA ME);
format(failas,43,"\\saves\\cars\\%s.ini",ZaidejoVa rdas);
if(dini_Exists(failas))
{
new Transportas = CreateVehicle(dini_Int(failas,"Modelis"),dini_Floa t(failas,"X"),dini_Float(failas,"Y"),dini_Float(fa ilas,"Z"),dini_Float(failas,"F"),dini_Int(failas," Spalva1"),dini_Int(failas,"Spalva2"),-1);
if(dini_Int(failas,"Paintjob") != 0) ChangeVehiclePaintjob(Transportas,dini_Int(failas, "Paintjob"));
vehicleDB[Transportas][locked] = true;
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(Transportas,i,0,1); // uzrakinimas
}
}
format(vehicleDB[Transportas][owner_name],MAX_PLAYER_NAME,"%s",ZaidejoVardas);
vehicleDB[Transportas][gas] = dini_Int(failas,"Degalai");
if(dini_Int(failas,"Tune0") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une0"));
if(dini_Int(failas,"Tune1") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une1"));
if(dini_Int(failas,"Tune2") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une2"));
if(dini_Int(failas,"Tune3") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une3"));
if(dini_Int(failas,"Tune4") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une4"));
if(dini_Int(failas,"Tune5") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une5"));
if(dini_Int(failas,"Tune6") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une6"));
if(dini_Int(failas,"Tune7") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une7"));
if(dini_Int(failas,"Tune8") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une8"));
if(dini_Int(failas,"Tune9") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une9"));
if(dini_Int(failas,"Tune10") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une10"));
if(dini_Int(failas,"Tune11") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une11"));
if(dini_Int(failas,"Tune12") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une12"));
if(dini_Int(failas,"Tune13") != 0) AddVehicleComponent(Transportas,dini_Int(failas,"T une13"));
}
}

than, when player exit car:
Quote:

if(vehicleDB[vehicleid][locked])
{
SendClientMessage(playerid, MELYNA2,"Maрinos pozicija buvo iрsaugota.");
if(vehicleid == playerDB[playerid][pcar]) SaugojamMasina(playerid);
}

Reply
#2

First:
Quote:
Originally Posted by Gh0sT_
LOL.

Second: Making codes in your own language is pretty hard for other to help. Use english codes, thats better.

Third: Do you save the Vehicle's pos when the player leaves the car AND when he disconnects while he is in the car?
Reply
#3

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
First:
LOL.

Second: Making codes in your own language is pretty hard for other to help. Use english codes, thats better.

Third: Do you save the Vehicle's pos when the player leaves the car AND when he disconnects while he is in the car?
Second: Where u cant understand?
Third: No. When car owner exit the car, server save the car(SaugotiMasina). Then, when player loading information, car loaded too. (UzkrautiUzrakintaMasina). But, when player buy car, tune it. Leave the server ( saving OK, loading too. ) Than, connect again, get your own car, drive it somewhere, and than log off. When you do server restart, the player's cars pos seting to first saved pos. (T.y first place, where they exited they own car. )
Reply
#4

Hm...can you show what you added when he leaves the car, and under OnPlayerDisconnect.
And it would be usefull if you can explain the problem in points, easier to understand, like this:

- Enter car
- Exit car => Save car
- ...
Reply
#5

- Buy Car.
- Tune it.
- Exit. (Saves ok)
- Log in again
- Get that car, before u relog'ed. ( ur own )
- Drive it anywhere.
- Log out
- Car pos sets to first saved pos ( this time: where u exited first time, when u buy ur car )
Reply
#6

Is Step 3 "Exit" and Step 7 "Log Out" the same?

Or do you mean, Exit => Leave Car, and Log Out => Leave server ?
Reply
#7

Nah.. When u buy the vehicle(Step1) you need to tune it(step2). Than, drive it anywhere, and do relog. (First time saving OK.). Than, log in. Get in car, and drive in anywhere again, than log out. - Car pos set to first relog place.
Reply
#8

Bump, sorryyyy..
Reply
#9

Bump only if left for 12 hours.
Reply
#10

OFFT: Are you releasing this code?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)