MySQL
#1

Okay this might be a big problem but i can't find solution so I tought you could help me..
PHP код:
CMD:createhouse(playeridparams[])
{
    if(
PlayerInfo[playerid][Admin] < 5)
    {
        
ERROR(playerid"You are not allowed to use this command");
        return 
1;
    }
    new 
typelevelprice;
    if(
sscanf(params"iii"typelevelprice))
    {
        
USAGE(playerid"/createhouse [Type] [Level] [Price]");
        
INFO(playerid"Type | 1 - Camp House | 2 - Small House | 3 - Medium House");
        
INFO(playerid"Type | 4 - Big House | 5 - Villa");
        return 
1;
    }
    if(
type || type 5)
    {
        
ERROR(playerid"Type can't be higher than 5 and lower than 1");
        return 
1;
    }
    if(
level || level 100)
    {
        
ERROR(playerid"Level can't be higher than 100 and lower than 1");
        return 
1;
    }
    if(
price 1)
    {
        
ERROR(playerid"Price can't be lower than 1$");
        return 
1;
    }
    new 
house;
    if(
HouseInfo[house][hID] > MAX_HOUSES)
    {
        
ERROR(playerid"Max houses reached!");
        return 
1;
    }
    if(
type == 1)
    {
        
HouseInfo[hID][hExitX] = 327.4407;
        
HouseInfo[hID][hExitY] = 1766.7507;
        
HouseInfo[hID][hExitZ] = 4.9849;
        
HouseInfo[hID][hType] = TYPE_CAMP;
        
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
        
HouseInfo[hID][hInt] = 2;
    }
    else if(
type == 2)
    {
        
HouseInfo[hID][hExitX] = 2308.7529;
        
HouseInfo[hID][hExitY] = -1212.5588;
        
HouseInfo[hID][hExitZ] = 1049.0234;
        
HouseInfo[hID][hType] = TYPE_SMALL;
        
strmid(HouseInfo[hID][hDescription], "Description",0,strlen("Description"),255);
        
HouseInfo[hID][hInt] = 6;
    }
    else if(
type == 3)
    {
        
HouseInfo[hID][hExitX] = 318.6055;
        
HouseInfo[hID][hExitY] = 1114.9292;
        
HouseInfo[hID][hExitZ] = 1083.8828;
        
HouseInfo[hID][hType] = TYPE_MEDIUM;
        
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
        
HouseInfo[hID][hInt] = 5;
    }
    else if(
type == 4)
    {
        
HouseInfo[hID][hExitX] = 386.6623;
        
HouseInfo[hID][hExitY] = 1471.7719;
        
HouseInfo[hID][hExitZ] = 1080.1875;
        
HouseInfo[hID][hType] = TYPE_BIG;
        
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
        
HouseInfo[hID][hInt] = 15;
    }
    else if(
type == 5)
    {
        
HouseInfo[hID][hExitX] = 2324.3840;
        
HouseInfo[hID][hExitY] = -1149.0188;
        
HouseInfo[hID][hExitZ] = 1050.7101;
        
HouseInfo[hID][hType] = TYPE_VILLA;
        
strmid(HouseInfo[hID][hDescription],"Description",0,strlen("Description"),255);
        
HouseInfo[hID][hInt] = 12;
    }
    new 
Float:XFloat:YFloat:Z;
    
house Iter_Free(i_Houses);
    
GetPlayerPos(playeridXYZ);
    
HouseInfo[house][hID] = house;
    
HouseInfo[house][hVW] = house;
    
HouseInfo[house][hOwnerCheck] = 0;
    
strmid(HouseInfo[house][hOwnerName], "Noone"0strlen("Noone"), 255);
    
HouseInfo[house][hEnterX] = X;
    
HouseInfo[house][hEnterY] = Y;
    
HouseInfo[house][hEnterZ] = Z;
    
HouseInfo[house][hLevel] = level;
    
HouseInfo[house][hPrice] = price;
    
HouseInfo[house][hMoney] = 0;
    
HouseInfo[house][hLocked] = 1;
    
HouseInfo[house][hWeapons] = -1;
    
HouseInfo[house][hAmmo] = 0;
    
HouseInfo[house][hRent]= 0;
    
HouseInfo[house][hRentPrice] = 20;
    
HouseInfo[house][hBell] = 0;
    
HouseInfo[house][hDrugs] = 0;
    
HouseInfo[house][HouseExist] = true;
    
Iter_Add(i_Houseshouse);
    
CreateHouses(house);
    new 
query[600];
    
mysql_format(g_SQLquerysizeof(query), "INSERT INTO `houses` (`ID`,`OwnerCheck`, `OwnerName`, `Description`, `Type`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Level`, `Price`, `Money`, `Interior`, `VW`, `Locked`, `Rent`, `RentPrice`, `Weapons`, `Ammo`, `Bell`, `Drugs`)\
    VALUES (%d, %d, '%s', '%s', %d, %f, %f, %f, %f, %f, %f, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)"
,
    
HouseInfo[house][hID], HouseInfo[house][hOwnerCheck], HouseInfo[house][hOwnerName], HouseInfo[house][hDescription], HouseInfo[house][hType], HouseInfo[house][hEnterX], HouseInfo[house][hEnterY], HouseInfo[house][hEnterZ], HouseInfo[house][hExitX], HouseInfo[house][hExitY], HouseInfo[house][hExitZ], HouseInfo[house][hLevel], HouseInfo[house][hPrice], HouseInfo[house][hMoney], HouseInfo[house][hInt], HouseInfo[house][hVW], HouseInfo[house][hLocked], HouseInfo[house][hRent],
    
HouseInfo[house][hRentPrice], HouseInfo[house][hWeapons], HouseInfo[house][hAmmo], HouseInfo[house][hBell], HouseInfo[house][hDrugs]);
    
mysql_tquery(g_SQLquery);
    return 
1;

That is /createhouse command.. Problem is when I create first house as type 5 (Villa) it will be created as villa.. but every other house will be created as camp house.. Any ideas why is this happening??

But it is saved in mysql table as villa.. WTF..

Here are functions
PHP код:
HouseType(id)
{
    new 
string[17];
    switch(
id)
    {
        case 
TYPE_CAMPstring "Camp House";
        case 
TYPE_SMALLstring "Small House";
        case 
TYPE_MEDIUMstring "Medium House";
        case 
TYPE_BIGstring "Big House";
        case 
TYPE_VILLAstring "Villa";
        default: 
string "Unknown";
    }
    return 
string;
}
CreateHouses(id)
{
    if(
HouseInfo[id][hOwnerCheck] == 0)
    {
        new 
string[320];
        
format(stringsizeof(string), ""SERVERBLUE"House on sale\n"SERVERBLUE"Type: "WHITE"%s\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"To buy house type /buyhouse"HouseType(HouseInfo[id][hType]), HouseInfo[id][hPrice], HouseInfo[id][hLevel]);
        
HouseLabel[id] = CreateDynamic3DTextLabel(string0x1D9F00AAHouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.125.0___00__);
        
HousePickup[id] = CreateDynamicPickup(12731HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
    }
    else if(
HouseInfo[id][hOwnerCheck] == 1)
    {
        new 
string[320], string2[220], string3[540];
        if(
HouseInfo[id][hRent] == 0)
        {
            
format(stringsizeof(string), ""SERVERBLUE"[ "WHITE"%s "SERVERBLUE"]\n"SERVERBLUE"Owner: "WHITE"%s\b"SERVERBLUE"Type: "WHITE"%d\n"HouseInfo[id][hDescription], HouseInfo[id][hOwnerName], HouseInfo[id][hType]);
            
format(string2sizeof(string2), ""SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"To enter press 'F' or 'ENTER'"HouseInfo[id][hLevel], HouseInfo[id][hPrice]);
            
format(string3sizeof(string3), "%s%s"stringstring2);
            
HouseLabel[id] = CreateDynamic3DTextLabel(string30x1D9F00AAHouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.125.0___00__);
            
HousePickup[id] = CreateDynamicPickup(12731HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
        }
        else if(
HouseInfo[id][hRent] == 1)
        {
            
format(stringsizeof(string), ""SERVERBLUE"[ "WHITE"%s "SERVERBLUE"]\n"SERVERBLUE"Owner: "WHITE"%s\b"SERVERBLUE"Type: "WHITE"%d\n"SERVERBLUE"Rent: "WHITE"%d$(/renthouse)"HouseInfo[id][hDescription], HouseInfo[id][hOwnerName], HouseInfo[id][hType], HouseInfo[id][hRentPrice]);
            
format(string2sizeof(string2), ""SERVERBLUE"Level: "WHITE"%d\n"SERVERBLUE"Price: "WHITE"%d\n"SERVERBLUE"To enter press 'F' or 'ENTER'"HouseInfo[id][hLevel], HouseInfo[id][hPrice]);
            
format(string3sizeof(string3), "%s%s"stringstring2);
            
HouseLabel[id] = CreateDynamic3DTextLabel(string30x1D9F00AAHouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]+0.125.0___00__);
            
HousePickup[id] = CreateDynamicPickup(12731HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
        }
    }
    return 
1;

Reply


Messages In This Thread
MySQL - by Micko123 - 25.11.2016, 18:11
Re: MySQL - by Vince - 25.11.2016, 18:17
Re: MySQL - by Micko123 - 25.11.2016, 18:25
Re: MySQL - by Micko123 - 25.11.2016, 20:22
Re: MySQL - by Alvitr - 25.11.2016, 20:50
Re: MySQL - by Micko123 - 26.11.2016, 19:35
Re: MySQL - by Micko123 - 26.11.2016, 19:50
Re: MySQL - by Micko123 - 26.11.2016, 20:01
Re: MySQL - by Micko123 - 26.11.2016, 20:53

Forum Jump:


Users browsing this thread: 3 Guest(s)