SQL -> Vehicle saving
#8

Mmm.. I have these 2 stocks:
PHP код:
stock getPlayerSqlID(pid) return player[pid][pSqlID];
stock setPlayerSqlID(pididplayer[pid][pSqlID] = id
I use it here:
PHP код:
stock playerExist(pid)
{
    new const 
Result:sql_query(sql,
        
f("SELECT id FROM "MySQL_PLAYERS_TABLE" WHERE pName = '%s'"getPlayerName(pid)),
        
QUERY_CACHED
    
);
    if(
sql_num_rows(r))
    {
        
setPlayerSqlID(pidsql_get_field_assoc_int(r"id"));
        return 
true;
    
    } else {
        return 
false;
    }

PHP код:
stock registerPlayer(pid)
{
    
inline register(iddidresponselistitemstring:inputtext[])
    {
        
#pragma unused id, did, listitem
        
if(response)
        {
            if(
isnull(inputtext))
            {
                
registerPlayer(pid);
            
            } else {
                new 
pw[130];
                
WP_Hash(pwsizeof pwinputtext);
                new const 
Result: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(pidsql_insert_id(r));
                
set.fPrisijunge[pid] = true;
                
OnPlayerRegister(pid);
            }
        } else {
            
Kick(pid);
        }
    }
    
showDialog(pidusing inline registerDIALOG_STYLE_INPUT"{FFC13B}•{ffffff} REGISTRACIJA""Įvesk naują slaptaћodį:""Jungtis""");

So how should I place this SQL it to vehicle id?
On Player buys vehicle:
PHP код:
YCMD:pirkti(playeridparams[], help)
{
    if(
playerCar1 playerid ] != -1) return SendError(playerid"jūs jau turite transportą !");
    
printf("lol1");
    if( 
vehSelectedplayerid ] == sportCars ) return 0;
    
printf("lol2");
    if( 
soldCarsvehSelected playerid ] ][ soldPrice ] > getPlayerMoneyplayerid ) ) return SendErrorplayerid"Neuћtenka pinigų transportui!" )   ;
    
givePlayerMoney(playerid, -soldCarsvehSelected playerid ] ][ soldPrice ]);
    
printf("lol3");
    
playerCar1 playerid ] = CreateVehicle soldCarsvehSelectedplayerid ]][ soldModel ], -1979.8074,270.152190,0000ChosenColor[playerid], ChosenColor[playerid], -) ;
    
format masina playerCar1 playerid ] ] [ vehOwner ] , 50 "%s" getPlayerName playerid ) ) ;
    for ( new 
tune 0tune 13tune++ ) masina playerCar1 playerid ] ] [ vehTune ] [ tune ] = 0;
    for ( new 
color 0color 2color++ ) 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 ] [ ] = -1979.8074;
    
masina playerCar1 playerid ] ] [ vehLastPos ] [ ] = 270.1521 ;
    
masina playerCar1 playerid ] ] [ vehLastPos ] [ ] = 35.0415 ;
    
masina playerCar1 playerid ] ] [ vehLastPos ] [ ] = 90.0000 ;
    
masina playerCar1 playerid ] ] [ vehModel ] = soldCarsvehSelectedplayerid ]][ soldModel ];
    
masina playerCar1 playerid ] ] [ vehOwned ] = true;
    
SetVehicleParamsEx playerCar1 playerid ], falsefalsefalsefalsefalsefalsefalse ) ;
    new 
query 200 ];
    
format query sizeof query ) , "NEREGISTRUOTA") ;
    
SetVehicleNumberPlate playerCar1 playerid ] , query) ;
    
format masina playerCar1 playerid ] ] [ vehNumber ] , 21 "%s" query ) ;
    
format(g_szBuffersizeof 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')"
, \ 
    
masinaplayerCar1 playerid ] ][ vehOwner ],
    
masinaplayerCar1 playerid ] ][ vehModel ], 
    
masinaplayerCar1 playerid ] ][ vehLastPos ][0],
    
masinaplayerCar1 playerid ] ][ vehLastPos ][1], 
    
masinaplayerCar1 playerid ] ][ vehLastPos ][2],
    
masinaplayerCar1 playerid ] ][ vehLastPos ][3],
    
ChosenColor[playerid],
     
ChosenColor[playerid],
    
masinaplayerCar1 playerid ] ][ vehKaina ], 
    
masinaplayerCar1 playerid ] ][ Gas ], 
    
masinaplayerCar1 playerid ] ][ vehNumber ]);
    
sql_query(sqlg_szBufferQUERY_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(playerid0);
    
//SendClientMessage(playerid, 0xFFFFFFAA, "isejai is car shopo :).");
    
hideCarShop(playerid);
    
DestroyVehiclepreVehplayerid ] )    ;
    
SetCameraBehindPlayerplayerid );
    
TogglePlayerControllableplayerid) ;
    return 
1;

Still it no sense, the info should save by name...
Reply


Messages In This Thread
SQL -> Vehicle saving - by bogushas - 13.12.2014, 08:09
Re: SQL -> Vehicle saving - by bogushas - 13.12.2014, 10:41
Re: SQL -> Vehicle saving - by Vince - 13.12.2014, 10:55
Re: SQL -> Vehicle saving - by bogushas - 13.12.2014, 13:24
Re: SQL -> Vehicle saving - by bogushas - 13.12.2014, 13:56
Re: SQL -> Vehicle saving - by Kaperstone - 13.12.2014, 14:30
Re: SQL -> Vehicle saving - by PowerPC603 - 13.12.2014, 14:41
Re: SQL -> Vehicle saving - by bogushas - 13.12.2014, 15:26

Forum Jump:


Users browsing this thread: 1 Guest(s)