SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/07/2018, 10:08 AM   #1
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Why label not showing?

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 Code:
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 Code:
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 Code:
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 Code:
format(querysizeof(query), "SELECT * FROM sam");
    
mysql_function_query(dbhandlequerytrue"OnSAMLoad"""); 
OnSAMLoad:
PHP Code:
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;

__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 07/07/2018, 12:20 PM   #2
Slawi
Little Clucker
 
Join Date: Dec 2013
Posts: 48
Reputation: 1
Default Re: Why label not showing?

Quote:
Originally Posted by akib View Post
OnSAMLoad:
PHP Code:
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 ??
Slawi is offline   Reply With Quote
Old 07/07/2018, 12:54 PM   #3
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Re: Why label not showing?

Quote:
Originally Posted by Slawi View Post
your first row in "id" in database start with 0 or 1 ??
it's start with 1
__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 07/07/2018, 03:59 PM   #4
Slawi
Little Clucker
 
Join Date: Dec 2013
Posts: 48
Reputation: 1
Default Re: Why label not showing?

EDITED;

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

and it will be showing when you creating it
Slawi is offline   Reply With Quote
Old 07/07/2018, 10:48 PM   #5
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 34
Reputation: 51
Default Re: Why label not showing?

First destroy label then create him, that should work try it.
OsmanMalagic is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3dtext label not showing PowerF Scripting Help 3 22/07/2015 03:41 PM
3D text label not showing up DarkLored Scripting Help 3 17/07/2015 05:10 AM
3D text label not showing Blademaster680 Scripting Help 2 18/07/2014 05:26 PM
3D Label Not showing Gamer_007 Scripting Help 6 06/02/2013 09:43 AM
3D Text Label not showing Dripac Scripting Help 0 25/03/2012 02:59 PM


All times are GMT. The time now is 04:37 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.