SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 23/01/2019, 11:32 AM   #1
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Function not calling

I don't know why function OnDoorsLoad calling...

Code:
PHP Code:
CMD:door(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3) return    SendClientMessage(playeridCOLOR_ORANGE"Error: {ffffff}You're not authorized to use this command.");
    new 
Float:xFloat:yFloat:z;
    new 
str[280],m[512];
    for(new 
1MAX_DOORSi++)
    {
      if(
DynamicDoor[i][dUsed] == 0)
      {
            
GetPlayerPos(playeridxyz);
            
DynamicDoor[i][dUsed] = 1;
            
DynamicDoor[i][posX] = x;
            
DynamicDoor[i][posY] = y;
            
DynamicDoor[i][posZ] = z;
            
DynamicDoor[i][dOutWorld] = GetPlayerVirtualWorld(playerid);
            
DynamicDoor[i][dOutInt] = GetPlayerInterior(playerid);

            
format(msizeof(m), "INSERT INTO doors (posX,posY,posZ,dOutWorld,dOutInt) VALUES ('%f','%f','%f','%i','%i')"DynamicDoor[i][posX],DynamicDoor[i][posY],DynamicDoor[i][posZ],DynamicDoor[i][dOutWorld],DynamicDoor[i][dOutInt]);
            
printf("%s"m);
            
mysql_function_query(dbhandle,m,true,"OnDoorsLoad","");
            
printf("%d"mysql_function_query(dbhandle,m,true,"OnDoorsLoad",""));
            
format(strsizeof(str), "Sucess: {ffffff}You created Door ID: %d."i);
            
SendClientMessage(playeridCOLOR_LIMEstr);
            return 
1;
       }
    }
       return 
1;

Data inserting in MYSQL but function not calling
__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 23/01/2019, 11:44 AM   #2
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: Function not calling

what's mysql_function_query (Show the definition)? Also show OnDoorsLoad
SyS is offline   Reply With Quote
Old 23/01/2019, 11:48 AM   #3
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Re: Function not calling

Quote:
Originally Posted by SyS View Post
what's mysql_function_query ? Also show OnDoorsLoad
mysql_function_query is now mysql_tquery

Code OnDoorsLoad
PHP Code:
public OnDoorsLoad()
{
    new 
num_fields,num_rows,str[512];
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;
    print(
"========================| Loading Doors |=========================");
    for(new 
i=1;i<sizeof(DynamicDoor);i++){
        
DestroyPickup(DynamicDoor[i][dPickup]);
        
DestroyPickup(DynamicDoor[i][dOPickup]);
        
Delete3DTextLabel(DynamicDoor[i][dLabel]);
    }
    for(new 
i=0i<num_rowsi++)
    {
        new 
id=GetFreeDoorID();
        
DynamicDoor[id][doorID]=id;
        
DynamicDoor[id][dUsed]=1;
        
DynamicDoor[id][doorSQLID]=cache_get_field_content_int(i"id"dbhandle);
        
DynamicDoor[id][posX]=cache_get_field_content_float(i"posX"dbhandle);
        
DynamicDoor[id][posX]=cache_get_field_content_float(i"posX"dbhandle);
        
DynamicDoor[id][posY]=cache_get_field_content_float(i"posY"dbhandle);
        
DynamicDoor[id][posZ]=cache_get_field_content_float(i"posZ"dbhandle);
        
DynamicDoor[id][posi][0]=cache_get_field_content_float(i"posiX"dbhandle);
        
DynamicDoor[id][posi][1]=cache_get_field_content_float(i"posiY"dbhandle);
        
DynamicDoor[id][posi][2]=cache_get_field_content_float(i"posiZ"dbhandle);
        
DynamicDoor[id][dBarOne]=cache_get_field_content_int(i"bar"dbhandle);
        
DynamicDoor[id][dTreasury]=cache_get_field_content_int(i"dTreasury"dbhandle);
        
DynamicDoor[id][dFee]=cache_get_field_content_int(i"dFee"dbhandle);
        
DynamicDoor[id][dOutWorld]=cache_get_field_content_int(i"dOutWorld"dbhandle);
        
DynamicDoor[id][dOutInt]=cache_get_field_content_int(i"dOutInt"dbhandle);
        
DynamicDoor[id][dOwner]=cache_get_field_content_int(i"dOwner"dbhandle);
        
DynamicDoor[id][dWorld]=cache_get_field_content_int(i"dWorld"dbhandle);
        
DynamicDoor[id][dInterior]=cache_get_field_content_int(i"dInterior"dbhandle);
        
DynamicDoor[id][dLock]=cache_get_field_content_int(i"dLock"dbhandle);
        
cache_get_field_content(i"dName"DynamicDoor[i][dName], dbhandle);

        
DynamicDoor[id][dPickup] = CreatePickup(12391DynamicDoor[id][posX], DynamicDoor[id][posY], DynamicDoor[id][posZ], -1);
        
DynamicDoor[id][dOPickup] = CreatePickup(12391DynamicDoor[id][posi][0], DynamicDoor[id][posi][1], DynamicDoor[id][posi][2], -1);
        
format(strsizeof(str), "%s\n{ffffff}Type /enter to enter."DynamicDoor[i][dName]);
        
DynamicDoor[id][dLabel] = CreateDynamic3DTextLabel(str ,COLOR_ORANGEDynamicDoor[id][posX], DynamicDoor[id][posY], DynamicDoor[id][posZ],30.0INVALID_PLAYER_IDINVALID_VEHICLE_ID0, -1, -1, -17.0);

        
printf("Door %i[%i]: %f,%f,%f"DynamicDoor[id][doorSQLID],id,DynamicDoor[id][posX], DynamicDoor[id][posY], DynamicDoor[id][posZ]);
    }
    
printf("========================| Total Biz: %i |============================",num_rows);
    return 
1;

__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 23/01/2019, 12:04 PM   #4
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Re: Function not calling

Defination of mysq_function_query :
mysql_function_query( connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:... )


Source: https://forum.sa-mp.com/showthread.php?t=56564 (BlueG's post)
__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 23/01/2019, 12:39 PM   #5
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: Function not calling

You are performing INSERT query no result is returned
So basically your function is calling but it get stopped at if(!num_rows)return 1;
PHP Code:
public OnDoorsLoad()
{
    new 
num_fields,num_rows,str[512];
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;//here 
    //..............

as there are no rows returned num_rows is zero
SyS is offline   Reply With Quote
Old 23/01/2019, 12:55 PM   #6
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Re: Function not calling

Quote:
Originally Posted by SyS View Post
You are performing INSERT query no result is returned
So basically your function is calling but it get stopped at if(!num_rows)return 1;
PHP Code:
public OnDoorsLoad()
{
    new 
num_fields,num_rows,str[512];
    
cache_get_data(num_rows,num_fields,dbhandle);
    if(!
num_rows)return 1;//here 
    //..............

as there are no rows returned num_rows is zero

ahh shit, lemme change the code and try again, i will call select after inserting data?
__________________
ImKhan#4244
akib is offline   Reply With Quote
Old 23/01/2019, 01:00 PM   #7
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 283
Reputation: 2
Default Re: Function not calling

Fixed, thanks!
__________________
ImKhan#4244
akib 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
Calling function from PHP bartje01 Scripting Help 3 13/06/2016 09:40 PM
[Compiler] Calling a function from an include wups Scripting Help 2 24/09/2015 07:58 PM
Calling a function by ID DamonD Scripting Help 1 14/02/2015 03:19 PM
[Tutorial] Remote Function calling Lordzy Tutorials 5 05/07/2014 01:44 PM
[Help] Calling function via string BloodMaster Scripting Help 2 12/10/2011 05:00 PM


All times are GMT. The time now is 07:42 AM.


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