Why label not showing?
#1

Hello, i want to create a dynamic SAM system.



Old SAM label showing properly when i restart the whole server by restarting console
means if i create new SAM i have to restart the console :/

how i can create the label without restarting

Command : /buildsam
PHP код:
COMMAND:buildsam(playerid,params[])
{
    
editing 2;
    
GetPlayerPos(playerid,p_x,p_y,p_z);
    
tmp_sam[playerid] = CreateObject(3267p_xp_yp_z0.00.00.0);
    
EditObject(playeridtmp_sam[playerid]);
    
    return 
1;

EditObject:
PHP код:
if(editing ==2)
        {
            for(new 
i=0i<sizeof(SAInfo); i++)
            {
                if(
SAInfo[i][s_id]==0)
                {
                    
SAInfo[i][s_x] = fX;
                    
SAInfo[i][s_y] = fY;
                    
SAInfo[i][s_z] = fZ;
                    
SAInfo[i][s_rx] = fRotX;
                    
SAInfo[i][s_ry] = fRotY;
                    
SAInfo[i][s_rz] = fRotX;
                    
SAInfo[i][s_range] = 300;
                    
Create3DTextLabel("ok", -1fXfYfZ3000);
                    new 
query[256];
                    
format(querysizeof(query),"INSERT INTO sam (s_x, s_y, s_z, s_rx, s_ry, s_rz, s_range, s_type) VALUES ('%f', '%f', '%f', '%f', '%f', '%f','%i', '%s')",SAInfo[i][s_x], SAInfo[i][s_y], SAInfo[i][s_z], SAInfo[i][s_rx], SAInfo[i][s_ry], SAInfo[i][s_rz],SAInfo[i][s_range], "Blown");
                    
mysql_function_query(dbhandlequerytrue"OnSamCreated""");
                    
                    
SendClientMessage(playerid,COLOR_GREEN,"SAM created successfully!");    
                    
DestroyObject(tmp_sam[playerid]);
                    
                    return 
1;
                }
            }
            return 
1;
        } 
UpdateSAM :
PHP код:
UpdateSAM(id)
{
    if(
strlen(SAInfo[id][s_id])){
        new 
string[138];
        
SAInfo[id][s_obj]=CreateObject(3267SAInfo[id][s_x], SAInfo[id][s_y], SAInfo[id][s_z], SAInfo[id][s_rx], SAInfo[id][s_ry], SAInfo[id][s_rz]);
        
format(stringsizeof(string), "SAM ID : %i\nSAM Type : %s\nRange : %i\n{FF2400}Enabled"id,SAInfo[id][s_type],SAInfo[id][s_range]);
        
SAInfo[id][s_label] = Create3DTextLabel(stringCOLOR_WHITESAInfo[id][s_x], SAInfo[id][s_y], SAInfo[id][s_z], 300,0);
    }
    
    return 
1;

OnGameModeInit:
PHP код:
format(querysizeof(query), "SELECT * FROM sam");
    
mysql_function_query(dbhandlequerytrue"OnSAMLoad"""); 
OnSAMLoad:
PHP код:
public OnSAMLoad()
{
    new 
num_fields,num_rows;
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;
    for(new 
i=0i<num_rowsi++)
     {
         
SAInfo[i][s_id]=cache_get_field_content_int(i"id",dbhandle);
        
SAInfo[i][s_x]=cache_get_field_content_float(i"s_x",dbhandle);
        
SAInfo[i][s_y]=cache_get_field_content_float(i"s_y",dbhandle);
        
SAInfo[i][s_z]=cache_get_field_content_float(i"s_z",dbhandle);
        
SAInfo[i][s_rx]=cache_get_field_content_float(i"s_rx",dbhandle);
        
SAInfo[i][s_ry]=cache_get_field_content_float(i"s_ry",dbhandle);
        
SAInfo[i][s_rz]=cache_get_field_content_float(i"s_rz",dbhandle);
        
SAInfo[i][s_range]=cache_get_field_content_int(i"s_range"dbhandle);
        new 
tmp_type[20];
        
cache_get_field_content(i"s_type"tmp_type);
        
strmid(SAInfo[i][s_type], tmp_type0sizeof(tmp_type), sizeof(tmp_type));
        
//new m[126];
        //format(m, sizeof(m), "ICON POST : %f,%f,%f | Interiror : %f,%f,%f", bInfo[id][b_x],bInfo[id][b_y],bInfo[id][b_z],bInfo[id][b_ix],bInfo[id][b_iyy],bInfo[id][b_izz]);
        //SendClientMessageToAll(-1, m);
        
UpdateSAM(i);
        
     }
    return 
1;

Reply
#2

Quote:
Originally Posted by akib
Посмотреть сообщение
OnSAMLoad:
PHP код:
public OnSAMLoad()
{
    new 
num_fields,num_rows;
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;
    for(new 
i=0i<num_rowsi++)
     {
         
SAInfo[i][s_id]=cache_get_field_content_int(i"id",dbhandle);
        
SAInfo[i][s_x]=cache_get_field_content_float(i"s_x",dbhandle);
        
SAInfo[i][s_y]=cache_get_field_content_float(i"s_y",dbhandle);
        
SAInfo[i][s_z]=cache_get_field_content_float(i"s_z",dbhandle);
        
SAInfo[i][s_rx]=cache_get_field_content_float(i"s_rx",dbhandle);
        
SAInfo[i][s_ry]=cache_get_field_content_float(i"s_ry",dbhandle);
        
SAInfo[i][s_rz]=cache_get_field_content_float(i"s_rz",dbhandle);
        
SAInfo[i][s_range]=cache_get_field_content_int(i"s_range"dbhandle);
        new 
tmp_type[20];
        
cache_get_field_content(i"s_type"tmp_type);
        
strmid(SAInfo[i][s_type], tmp_type0sizeof(tmp_type), sizeof(tmp_type));
        
//new m[126];
        //format(m, sizeof(m), "ICON POST : %f,%f,%f | Interiror : %f,%f,%f", bInfo[id][b_x],bInfo[id][b_y],bInfo[id][b_z],bInfo[id][b_ix],bInfo[id][b_iyy],bInfo[id][b_izz]);
        //SendClientMessageToAll(-1, m);
        
UpdateSAM(i);
        
     }
    return 
1;

your first row in "id" in database start with 0 or 1 ??
Reply
#3

Quote:
Originally Posted by Slawi
Посмотреть сообщение
your first row in "id" in database start with 0 or 1 ??
it's start with 1
Reply
#4

EDITED;

when you create it use UpdateSAM(i); under OnSAMCreated check editing == 2

and it will be showing when you creating it
Reply
#5

First destroy label then create him, that should work try it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)