Jump to content
  • 0

Sistem masini mysql


TzAkS

Question

7 answers to this question

Recommended Posts

Am facut un sistem de masini personale pe mysql,masina se creaza cand este folosita comanda.

La id-ul masinii folosesc Auto_Increment..dar nu reusesc sa setez cheia masinii la playeri.Asta trebuie tot prin mysql.

Vreo idee?

postezi codul sa te putem ajuta..

vrei ca masina sa fie setata cat timp playerul e offline/online?

Link to comment
Share on other sites

Nu ai inteles,deci playerul cumpara o masina,cand playerul o cumpara atunci este creata.

Dar nu reusesc sa ii trec cheia de la masina pe numele lui atunci cand o cumpara.

Nu am ce cod sa postez..vreau doar o idee cum as putea sa fac pe mysql.

dude, nu trebuie niciun cod mysql atunci cand el este conectat, folosesti:

[pawn]PlayerInfo[playerid][pPcarkey] = id;[/pawn]

sau ce ai tu. nu am de unde sa stiu cum ai codul, de asta ti-am spus, iar pt mysql:


new szName[MAX_PLAYER_NAME], szQuery[256];
GetPlayerName(playerid, szName, sizeof(szName));
format(szQuery, sizeof(szQuery), "UPDATE `tabelulptplayeri` SET CarKey = %d WHERE Name = '%s'", idmasina, szName);
mysql_query(szQuery);

posteaza variabilele si numele la tabele/row-uri ca se te pot ajuta :|

Link to comment
Share on other sites

    [pawn]if(dialogid == 12)

{

if(response)

{

    new id,description[16],value,license[16];

                new model = strval(inputtext);

                new Float:X,

Float:Y,

Float:Z,

Float:Angle;

new sendername[MAX_PLAYER_NAME];

new owner = GetPlayerName(playerid, sendername, sizeof(sendername));

X = 2783.9478; // Default Variable

Y = -2494.4778; // Default Variable

Z = 13.6550; // Default Variable

Angle = 85.6610; // Default Variable

//owner = "Dealership"; // Default Variable

license = "ForSale"; // Default Variable

id = mysql_num_rows()+1;

new Query[1024];

format(Query, sizeof(Query), "INSERT INTO `cars` (`ID`, `Model`, `Locationx`, `Locationy`, `Locationz`, `Angle`, `Owner`, `Description`, `Value`, `License`) VALUES ('%d','%d','%f','%f','%f','%f','%s','%s','%d','%s')",id,model,X,Y,Z,Angle,owner,description,value,license);

mysql_query(Query);

mysql_free_result();

SendClientMessage(playerid, COLOR_GREY, "Masina ta va fi adusa la docuri Los Santos in 2 ore!");

CreateVehicle(model,X,Y,Z,Angle,0,0,99999);

}

else

{

SendClientMessage(playerid, COLOR_GREY, "Ai refuzat sa cumperi.");

}

}[/pawn]

Chestia e ca eu folosesc asta dintr-un dialog,daca era din comanda era mai usor.

Si pentru cheie am incercat asa.

[pawn]new wakaname[25];

GetPlayerName(playerid,wakaname,25);

new str[128];

format(str,128,"UPDATE `players` SET `CarKey`='%d' WHERE `name`='%s'",id,wakaname);

mysql_query(Query);[/pawn]

gXvsYS
Link to comment
Share on other sites

[pawn]id = mysql_insert_id();[/pawn]

apoi foloseste

[pawn]PlayerInfo[playerid][pPcarkey] = id;[/pawn]

btw: nu trebuie sa creezi variabile pentru x, y, z, angle etc..

[pawn]

format(Query, sizeof(Query), "INSERT INTO `cars` (`Model`, `Locationx`, `Locationy`, `Locationz`, `Angle`, `Owner`, `Description`, `Value`, `License`) VALUES ('%d','2783.9478', '-2494.4778', '13.6550', '85.6610','%s','%s','%d','%s')",model,sendername,description,value,license);

CreateVehicle(model, CarInfo[id][cLocationx], CarInfo[id][cLocationy], CarInfo[id][cLocationz], CarInfo[id][cAngle], 999999);[/pawn]

+ ca value nu e definit => o sa fie = 0, la fel si license.. modelul este introdus prin dialog, daca pui de ex 612 (care nu exista) vor aparea buguri

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.