sqlite help
#1

PHP код:
CMD:createhouse(playerid,params[])
{
    new 
price;
    if(
sscanf(params,"d",price)) return SCM(playerid,-1,"USAGE:/createhouse [house price]");
//    if(pInfo[playerid][pAdmin] >= 4)
    
{
        new 
Float:pPos[3];
        
GetPlayerPos(playerid,pPos[0],pPos[1],pPos[2]);
        new 
DBResult:result;
        
result db_query(houses,"SELECT FROM `Houses` WHERE `Set`='1'");
        if(
db_num_rows(result) >= MAX_HOUSES) return SCM(playerid,-1,"You cannot create anymore houses!");
        
result db_query(houses,"INSERT INTO `Houses` (`EnterX`,`EnterY`,`EnterZ`,`EnterVw`,`EnterInt`,`Set`,`Owned`,`Price`)VALUES (`pPos[0]`,`pPos[1]`,`pPos[2]`,`GetPlayerVirtualWorld(playerid)`,`GetPlayerInterior(playerid)`,`1`,`0`,`price`)");
        new 
query[256];
        
format(query,sizeof(query),"SELECT FROM `Houses` WHERE `EnterX`='%f' LIMIT 1",pPos[0]);
        
result db_query(houses,query);
        
hInfo[db_num_rows(result)][hEntrance][0] = pPos[0];
        
hInfo[db_num_rows(result)][hEntrance][1] = pPos[1];
        
hInfo[db_num_rows(result)][hEntrance][2] = pPos[2];
        
hInfo[db_num_rows(result)][hEntranceVw] = GetPlayerVirtualWorld(playerid);
        
hInfo[db_num_rows(result)][hEntranceInt] = GetPlayerInterior(playerid);
        
hPickup[db_num_rows(result)] = CreateDynamicPickup(1273,19,hInfo[db_num_rows(result)][hEntrance][0],hInfo[db_num_rows(result)][hEntrance][1],
        
hInfo[db_num_rows(result)][hEntrance][2], GetPlayerVirtualWorld(playerid),GetPlayerVirtualWorld(playerid),-1,100.0);
        
hInfo[db_num_rows(result)][hSet] = true;
        
hInfo[db_num_rows(result)][hOwned] = false;
        
hInfo[db_num_rows(result)][hPrice] = price;
        
db_free_result(result);
    }
    return 
1;

This doesn't add the row to the databases table, all that happens when i use it, is the pickup spawns then disappears less then 1 second later, using the most up to date streamer plugin too. Any input would be greatly appreciated still kind of new to sqlite.
Reply
#2

In the line
pawn Код:
INSERT INTO `Houses` (`EnterX`,`EnterY`,`EnterZ`,`EnterVw`,`EnterInt`,`Set`,`Owned`,`Price`)VALUES (`pPos[0]`,`pPos[1]`,`pPos[2]`,`GetPlayerVirtualWorld(playerid)`,`GetPlayerInterior(playerid)`,`1`,`0`,`price`)");
You're literally trying to write fields in with "pPos[0]". Make a string and format those variables into it accordingly.
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
In the line
pawn Код:
INSERT INTO `Houses` (`EnterX`,`EnterY`,`EnterZ`,`EnterVw`,`EnterInt`,`Set`,`Owned`,`Price`)VALUES (`pPos[0]`,`pPos[1]`,`pPos[2]`,`GetPlayerVirtualWorld(playerid)`,`GetPlayerInterior(playerid)`,`1`,`0`,`price`)");
You're literally trying to write fields in with "pPos[0]". Make a string and format those variables into it accordingly.
oh wow, i derped big time on that one, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)