Mysql problem
#1

Hello every one im facting a problem. when i create an entrance in my server it show's the ID Like this

But on the DB i see id 0 so like that all entrances are commited that is bugged these are the codes
PHP код:
forward OnAdminCreateEntrance(playeridentranceidname[], Float:xFloat:yFloat:zFloat:angle);
public 
OnAdminCreateEntrance(playeridentranceidname[], Float:xFloat:yFloat:zFloat:angle)
{
    
strcpy(EntranceInfo[entranceid][eOwner], "Nobody"MAX_PLAYER_NAME);
    
strcpy(EntranceInfo[entranceid][eName], name40);
    
strcpy(EntranceInfo[entranceid][ePassword], "None"64);
    
EntranceInfo[entranceid][eExists] = 1;
    
EntranceInfo[entranceid][eID] = cache_insert_id(connectionID);
    
EntranceInfo[entranceid][eOwnerID] = 0;
    
EntranceInfo[entranceid][eIcon] = 1239;
    
EntranceInfo[entranceid][eLocked] = 0;
    
EntranceInfo[entranceid][eRadius] = 3.0;
    
EntranceInfo[entranceid][ePosX] = x;
    
EntranceInfo[entranceid][ePosY] = y;
    
EntranceInfo[entranceid][ePosZ] = z;
    
EntranceInfo[entranceid][ePosA] = angle;
    
EntranceInfo[entranceid][eIntX] = 0.0;
    
EntranceInfo[entranceid][eIntY] = 0.0;
    
EntranceInfo[entranceid][eIntZ] = 0.0;
    
EntranceInfo[entranceid][eIntA] = 0.0;
    
EntranceInfo[entranceid][eInterior] = 0;
    
EntranceInfo[entranceid][eWorld] = EntranceInfo[entranceid][eID] + 4000000;
    
EntranceInfo[entranceid][eOutsideInt] = GetPlayerInterior(playerid);
    
EntranceInfo[entranceid][eOutsideVW] = GetPlayerVirtualWorld(playerid);
    
EntranceInfo[entranceid][eAdminLevel] = 0;
    
EntranceInfo[entranceid][eFactionType] = FACTION_NONE;
    
EntranceInfo[entranceid][eGang] = -1;
    
EntranceInfo[entranceid][eVIP] = 0;
    
EntranceInfo[entranceid][eVehicles] = 0;
    
EntranceInfo[entranceid][eFreeze] = 0;
    
EntranceInfo[entranceid][eLabel] = 1;
    
EntranceInfo[entranceid][eType] = 0;
    
EntranceInfo[entranceid][eMapIcon] = 0;
    
EntranceInfo[entranceid][eText] = Text3D:INVALID_3DTEXT_ID;
    
EntranceInfo[entranceid][ePickup] = -1;
    
EntranceInfo[entranceid][eMapIconID] = -1;
    
EntranceInfo[entranceid][eColor] = -256;
    
Iter_Add(Entranceentranceid);
    
mysql_format(connectionIDqueryBuffersizeof(queryBuffer), "UPDATE entrances SET world = %i WHERE id = %i"EntranceInfo[entranceid][eWorld], EntranceInfo[entranceid][eID]);
    
mysql_tquery(connectionIDqueryBuffer);
    
ReloadEntrance(entranceid);
    
SendClientMessageEx(playeridCOLOR_GREEN"** Entrance %i created successfully."entranceid);

And this the entrances mysql input
PHP код:
CREATE TABLE `entrances` (
  `
idint(10NOT NULL,
  `
owneridint(10) DEFAULT '0',
  `
ownervarchar(24) DEFAULT NULL,
  `
namevarchar(40) DEFAULT NULL,
  `
iconidsmallint(5) DEFAULT '1239',
  `
lockedtinyint(1) DEFAULT '0',
  `
radiusfloat DEFAULT '3',
  `
pos_xfloat DEFAULT '0',
  `
pos_yfloat DEFAULT '0',
  `
pos_zfloat DEFAULT '0',
  `
pos_afloat DEFAULT '0',
  `
int_xfloat DEFAULT '0',
  `
int_yfloat DEFAULT '0',
  `
int_zfloat DEFAULT '0',
  `
int_afloat DEFAULT '0',
  `
interiortinyint(2) DEFAULT '0',
  `
worldint(10) DEFAULT '0',
  `
outsideinttinyint(2) DEFAULT '0',
  `
outsidevwint(10) DEFAULT '0',
  `
adminleveltinyint(2) DEFAULT '0',
  `
factiontypetinyint(2) DEFAULT '0',
  `
viptinyint(2) DEFAULT '0',
  `
vehiclestinyint(1) DEFAULT '0',
  `
freezetinyint(1) DEFAULT '0',
  `
passwordvarchar(64) DEFAULT 'None',
  `
labeltinyint(1) DEFAULT '1',
  `
mapicontinyint(3NOT NULL DEFAULT '0',
  `
gangtinyint(2) DEFAULT '-1',
  `
typetinyint(2) DEFAULT '0',
  `
colorint(10) DEFAULT '-256'
ENGINE=InnoDB DEFAULT CHARSET=latin1
Even if i create another entrance the ID 0 and the bug the interiors are commited
Reply
#2

I don't think the problem is in there...

Can you show me how you create the icons and the text above?

I think its in the way you use your iterate
Reply
#3

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
I don't think the problem is in there...

Can you show me how you create the icons and the text above?

I think its in the way you use your iterate
You mean this?
PHP код:
CMD:createentrance(playeridparams[])
{
    new 
name[40], Float:xFloat:yFloat:zFloat:a;
    if(
PlayerInfo[playerid][pAdmin] < && !PlayerInfo[playerid][pGangMod])
    {
        return 
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    }
    if(
sscanf(params"s[40]"name))
    {
        return 
SendClientMessage(playeridCOLOR_GREY3"[Usage]: /createentrance [name]");
    }
    if(
GetNearbyEntrance(playerid) >= 0)
    {
        return 
SendClientMessage(playeridCOLOR_GREY"There is an entrance in range. Find somewhere else to create this one.");
    }
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playerida);
    for(new 
0MAX_ENTRANCES++)
    {
        if(!
EntranceInfo[i][eExists])
        {
            
mysql_format(connectionIDqueryBuffersizeof(queryBuffer), "INSERT INTO entrances (name, pos_x, pos_y, pos_z, pos_a, outsideint, outsidevw) VALUES('%e', '%f', '%f', '%f', '%f', %i, %i)"namexyz180.0GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
            
mysql_tquery(connectionIDqueryBuffer"OnAdminCreateEntrance""iisffff"playeridinamexyza);
            return 
1;
        }
    }
    
SendClientMessage(playeridCOLOR_GREY"Entrance slots are currently full. Ask Kirito to increase the internal limit.");
    return 
1;

Reply
#4

No that's the create command. What I mean is when you create the icons.

This one

PHP код:
Create3DTextLabel(text[], colorFloat:XFloat:YFloat:ZFloat:DrawDistancevirtualworldtestLOS=0)
CreateDynamic3DTextLabel(const text[], colorFloat:xFloat:yFloat:zFloat:drawdistanceattachedplayer INVALID_PLAYER_IDattachedvehicle INVALID_VEHICLE_IDtestlos 0worldid = -1interiorid = -1playerid = -1Float:streamdistance STREAMER_3D_TEXT_LABEL_SDSTREAMER_TAG_AREA areaid STREAMER_TAG_AREA -1)
CreateDynamic3DTextLabelEx(const text[], colorFloat:xFloat:yFloat:zFloat:drawdistanceattachedplayer INVALID_PLAYER_IDattachedvehicle INVALID_VEHICLE_IDtestlos 0Float:streamdistance STREAMER_3D_TEXT_LABEL_SDworlds[] = { -}, interiors[] = { -}, players[] = { -}, STREAMER_TAG_AREA areas[] = { STREAMER_TAG_AREA -}, maxworlds sizeof worldsmaxinteriors sizeof interiorsmaxplayers sizeof playersmaxareas sizeof areas
I don't know which ones you are using.

Also to help you more, its when you buffer, load, or create the entrance of the house.
Reply
#5

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
No that's the create command. What I mean is when you create the icons.

This one

PHP код:
Create3DTextLabel(text[], colorFloat:XFloat:YFloat:ZFloat:DrawDistancevirtualworldtestLOS=0)
CreateDynamic3DTextLabel(const text[], colorFloat:xFloat:yFloat:zFloat:drawdistanceattachedplayer INVALID_PLAYER_IDattachedvehicle INVALID_VEHICLE_IDtestlos 0worldid = -1interiorid = -1playerid = -1Float:streamdistance STREAMER_3D_TEXT_LABEL_SDSTREAMER_TAG_AREA areaid STREAMER_TAG_AREA -1)
CreateDynamic3DTextLabelEx(const text[], colorFloat:xFloat:yFloat:zFloat:drawdistanceattachedplayer INVALID_PLAYER_IDattachedvehicle INVALID_VEHICLE_IDtestlos 0Float:streamdistance STREAMER_3D_TEXT_LABEL_SDworlds[] = { -}, interiors[] = { -}, players[] = { -}, STREAMER_TAG_AREA areas[] = { STREAMER_TAG_AREA -}, maxworlds sizeof worldsmaxinteriors sizeof interiorsmaxplayers sizeof playersmaxareas sizeof areas
I don't know which ones you are using.

Also to help you more, its when you buffer, load, or create the entrance of the house.
Here up
PHP код:
        if(EntranceInfo[entranceid][eLabel])
        {
            if(
EntranceInfo[entranceid][eOwnerID])
            {
                
format(stringsizeof(string), "%s\nOwner: %s\nPress 'Y' to go inside\n Entrance Id %d"EntranceInfo[entranceid][eName], EntranceInfo[entranceid][eOwner], entranceid);
            }
            else
            {
                
format(stringsizeof(string), "%s\nPress 'Y' to go inside\n Entrance Id %d."EntranceInfo[entranceid][eName], entranceid);
            }
            
EntranceInfo[entranceid][eText] = CreateDynamic3DTextLabel(stringCOLOR_GREY1EntranceInfo[entranceid][ePosX], EntranceInfo[entranceid][ePosY], (EntranceInfo[entranceid][eIcon] == 19902) ? (EntranceInfo[entranceid][ePosZ] + 0.1) : (EntranceInfo[entranceid][ePosZ]), 10.0, .worldid EntranceInfo[entranceid][eOutsideVW], .interiorid EntranceInfo[entranceid][eOutsideInt]);
        }
        
EntranceInfo[entranceid][ePickup] = CreateDynamicPickup(EntranceInfo[entranceid][eIcon], 1EntranceInfo[entranceid][ePosX], EntranceInfo[entranceid][ePosY], (EntranceInfo[entranceid][eIcon] == 19902) ? (EntranceInfo[entranceid][ePosZ] - 1.0) : (EntranceInfo[entranceid][ePosZ]), .worldid EntranceInfo[entranceid][eOutsideVW], .interiorid EntranceInfo[entranceid][eOutsideInt]); 
Reply
#6

Ahh I see the problem

PHP код:
    for(new 0MAX_ENTRANCES++) 
    { 
        if(!
EntranceInfo[i][eExists]) 
        { 
            
mysql_format(connectionIDqueryBuffersizeof(queryBuffer), "INSERT INTO entrances (name, pos_x, pos_y, pos_z, pos_a, outsideint, outsidevw) VALUES('%e', '%f', '%f', '%f', '%f', %i, %i)"namexyz180.0GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid)); 
            
mysql_tquery(connectionIDqueryBuffer"OnAdminCreateEntrance""iisffff"playeridinamexyza); 
            break; 
// Use break instead of return 1; It'll stop the loop.
        

    } 
Check this out link!

As I've seen the loop continues up to the MAX_ENTRANCES you have made for your server, it does not get stopped because you were using return and not break.
Reply
#7

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
Ahh I see the problem

PHP код:
    for(new 0MAX_ENTRANCES++) 
    { 
        if(!
EntranceInfo[i][eExists]) 
        { 
            
mysql_format(connectionIDqueryBuffersizeof(queryBuffer), "INSERT INTO entrances (name, pos_x, pos_y, pos_z, pos_a, outsideint, outsidevw) VALUES('%e', '%f', '%f', '%f', '%f', %i, %i)"namexyz180.0GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid)); 
            
mysql_tquery(connectionIDqueryBuffer"OnAdminCreateEntrance""iisffff"playeridinamexyza); 
            break; 
// Use break instead of return 1; It'll stop the loop.
        

    } 
Check this out link!

As I've seen the loop continues up to the MAX_ENTRANCES you have made for your server, it does not get stopped because you were using return and not break.
So just i need to add break on that then it will be sloved?
Reply
#8

Apparently yes, it should do it, if not then I'll ask another snippet from your code until we fix it. But that would do the trick as far as I can see, of what you have shown me.
Reply
#9

Quote:
Originally Posted by ScottMcBean
Посмотреть сообщение
Here up
PHP код:
        if(EntranceInfo[entranceid][eLabel])
        {
            if(
EntranceInfo[entranceid][eOwnerID])
            {
                
format(stringsizeof(string), "%s\nOwner: %s\nPress 'Y' to go inside\n Entrance Id %d"EntranceInfo[entranceid][eName], EntranceInfo[entranceid][eOwner], entranceid);
            }
            else
            {
                
format(stringsizeof(string), "%s\nPress 'Y' to go inside\n Entrance Id %d."EntranceInfo[entranceid][eName], entranceid);
            }
            
EntranceInfo[entranceid][eText] = CreateDynamic3DTextLabel(stringCOLOR_GREY1EntranceInfo[entranceid][ePosX], EntranceInfo[entranceid][ePosY], (EntranceInfo[entranceid][eIcon] == 19902) ? (EntranceInfo[entranceid][ePosZ] + 0.1) : (EntranceInfo[entranceid][ePosZ]), 10.0, .worldid EntranceInfo[entranceid][eOutsideVW], .interiorid EntranceInfo[entranceid][eOutsideInt]);
        }
        
EntranceInfo[entranceid][ePickup] = CreateDynamicPickup(EntranceInfo[entranceid][eIcon], 1EntranceInfo[entranceid][ePosX], EntranceInfo[entranceid][ePosY], (EntranceInfo[entranceid][eIcon] == 19902) ? (EntranceInfo[entranceid][ePosZ] - 1.0) : (EntranceInfo[entranceid][ePosZ]), .worldid EntranceInfo[entranceid][eOutsideVW], .interiorid EntranceInfo[entranceid][eOutsideInt]); 
I have maked 3 entrances here how they show up
Reply
#10

PHP код:
if(!EntranceInfo[i][eExists]) 
The variable does not get changed to 1, it also should be saved in your database.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)