13.12.2014, 15:26
Mmm.. I have these 2 stocks:
I use it here:
So how should I place this SQL it to vehicle id?
On Player buys vehicle:
Still it no sense, the info should save by name...
PHP код:
stock getPlayerSqlID(pid) return player[pid][pSqlID];
stock setPlayerSqlID(pid, id) player[pid][pSqlID] = id;
PHP код:
stock playerExist(pid)
{
new const Result:r = sql_query(sql,
f("SELECT id FROM "MySQL_PLAYERS_TABLE" WHERE pName = '%s'", getPlayerName(pid)),
QUERY_CACHED
);
if(sql_num_rows(r))
{
setPlayerSqlID(pid, sql_get_field_assoc_int(r, "id"));
return true;
} else {
return false;
}
}
PHP код:
stock registerPlayer(pid)
{
inline register(id, did, response, listitem, string:inputtext[])
{
#pragma unused id, did, listitem
if(response)
{
if(isnull(inputtext))
{
registerPlayer(pid);
} else {
new pw[130];
WP_Hash(pw, sizeof pw, inputtext);
new const Result:r = sql_query(sql,
f("INSERT INTO "MySQL_PLAYERS_TABLE" (pName, pPw) VALUES ('%s', '%s')", getPlayerName(pid), pw),
QUERY_NONE // none naudoti, kada reikia palaukti kol duomenys bus įraљyti į mysql
);
setPlayerSqlID(pid, sql_insert_id(r));
set.fPrisijunge[pid] = true;
OnPlayerRegister(pid);
}
} else {
Kick(pid);
}
}
showDialog(pid, using inline register, DIALOG_STYLE_INPUT, "{FFC13B}•{ffffff} REGISTRACIJA", "Įvesk naują slaptaћodį:", "Jungtis", "");
}
On Player buys vehicle:
PHP код:
YCMD:pirkti(playerid, params[], help)
{
if(playerCar1 [ playerid ] != -1) return SendError(playerid, "jūs jau turite transportą !");
printf("lol1");
if( vehSelected[ playerid ] == sportCars - 1 ) return 0;
printf("lol2");
if( soldCars[ vehSelected [ playerid ] ][ soldPrice ] > getPlayerMoney( playerid ) ) return SendError( playerid, "Neuћtenka pinigų transportui!" ) ;
givePlayerMoney(playerid, -soldCars[ vehSelected [ playerid ] ][ soldPrice ]);
printf("lol3");
playerCar1 [ playerid ] = CreateVehicle ( soldCars[ vehSelected[ playerid ]][ soldModel ], -1979.8074,270.1521, 90,0000, ChosenColor[playerid], ChosenColor[playerid], -1 ) ;
format ( masina [ playerCar1 [ playerid ] ] [ vehOwner ] , 50 , "%s" , getPlayerName ( playerid ) ) ;
for ( new tune = 0; tune < 13; tune++ ) masina [ playerCar1 [ playerid ] ] [ vehTune ] [ tune ] = 0;
for ( new color = 0; color < 2; color++ ) masina [ playerCar1 [ playerid ] ] [ vehColor ] [ color ] = ChosenColor[playerid];
masina [ playerCar1 [ playerid ] ] [ vehPaintjob ] = -1;
masina [ playerCar1 [ playerid ] ] [ lock ] = true;
masina [ playerCar1 [ playerid ] ] [ vehRida ] = 0.0;
masina [ playerCar1 [ playerid ] ] [ Gas ] = 40;
masina [ playerCar1 [ playerid ] ] [ vehLastPos ] [ 0 ] = -1979.8074;
masina [ playerCar1 [ playerid ] ] [ vehLastPos ] [ 1 ] = 270.1521 ;
masina [ playerCar1 [ playerid ] ] [ vehLastPos ] [ 2 ] = 35.0415 ;
masina [ playerCar1 [ playerid ] ] [ vehLastPos ] [ 3 ] = 90.0000 ;
masina [ playerCar1 [ playerid ] ] [ vehModel ] = soldCars[ vehSelected[ playerid ]][ soldModel ];
masina [ playerCar1 [ playerid ] ] [ vehOwned ] = true;
SetVehicleParamsEx ( playerCar1 [ playerid ], false, false, false, false, false, false, false ) ;
new query [ 200 ];
format ( query , sizeof ( query ) , "NEREGISTRUOTA") ;
SetVehicleNumberPlate ( playerCar1 [ playerid ] , query) ;
format ( masina [ playerCar1 [ playerid ] ] [ vehNumber ] , 21 , "%s" , query ) ;
format(g_szBuffer, sizeof g_szBuffer,
"INSERT INTO "MySQL_VEHICLE_TABLE" \
\
(savininkas, \
modelis, \
posX, \
posY, \
posZ, \
posA, \
spalva1, \
spalva2, \
kaina, \
degalai, \
numeriai) \
\
VALUES \
('%s', '%i', '%f', '%f', '%f', '%f', '%i', '%i', '%i', '%f', '%s')", \
masina[ playerCar1 [ playerid ] ][ vehOwner ],
masina[ playerCar1 [ playerid ] ][ vehModel ],
masina[ playerCar1 [ playerid ] ][ vehLastPos ][0],
masina[ playerCar1 [ playerid ] ][ vehLastPos ][1],
masina[ playerCar1 [ playerid ] ][ vehLastPos ][2],
masina[ playerCar1 [ playerid ] ][ vehLastPos ][3],
ChosenColor[playerid],
ChosenColor[playerid],
masina[ playerCar1 [ playerid ] ][ vehKaina ],
masina[ playerCar1 [ playerid ] ][ Gas ],
masina[ playerCar1 [ playerid ] ][ vehNumber ]);
sql_query(sql, g_szBuffer, QUERY_THREADED);
format ( query , sizeof ( query ) , "Nusipirkote transportą ( {f86000}%s{ffffff} ), kurio numeriai ( {f86000}%s{ffffff} ) !" , aVehicleNames [ masina [ playerCar1 [ playerid ] ] [ vehModel ] - 400 ], masina[playerCar1[playerid]][vehNumber] ) ;
SendClientMessage(playerid,-1,query);
CancelSelectTextDraw(playerid);
SetPlayerVirtualWorld(playerid, 0);
//SendClientMessage(playerid, 0xFFFFFFAA, "isejai is car shopo :).");
hideCarShop(playerid);
DestroyVehicle( preVeh[ playerid ] ) ;
SetCameraBehindPlayer( playerid );
TogglePlayerControllable( playerid, 1 ) ;
return 1;
}