Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Function does not load

 
  • 0 Vote(s) - 0 Average
Pawn Function does not load
Axitz
Offline

Burgershot Member
Posts: 24
Threads: 11
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#1
2021-04-15, 07:44 AM
Hi, my function does not load the giftboxes. Any idea why?

Function
Code:
function:OnLoadGiftboxes()
{
new rows = cache_num_rows(), iCount;
if(rows)
{
    new iGet[128];
    for(new i = 0; i != rows; i++)
    {
        cache_get_field_content(i, "gbox_x", iGet);
Giftboxes[i][gbox_x] = floatstr(iGet);
        cache_get_field_content(i, "gbox_y", iGet);
Giftboxes[i][gbox_y] = floatstr(iGet);
        cache_get_field_content(i, "gbox_z", iGet);
Giftboxes[i][gbox_z] = floatstr(iGet);
iCount++;
    }
}
ActivateGiftboxes(5);
printf("[Debug] Loaded %d/%d/%d giftboxes and 5 activations were sent.", iCount, rows, MAX_GIFTBOXES);
return 1;
}


Stock
Code:
stock ActivateGiftboxes(ggiftboxes)
{
for(new i = 0, l = ggiftboxes; i != l; i++)
{
    printf("%d loading", i);
    new gbox = minrand(0, MAX_GIFTBOXES);
    new gbox_i = minrand(1, 15);
    new gboxe_obj = 19054;
    if(gbox_i == 1)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 2)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 3)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 4)
    {
        gboxe_obj = 19057;
    }
    if(gbox_i == 5)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 6)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 7)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 8)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 9)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 10)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 11)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 12)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 13)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 14)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 15)
    {
        gboxe_obj = 19058;
    }
    Giftboxes[gbox][gbox_active] = true;
    Giftboxes[gbox][gbox_obj] = CreateDynamicObject(gboxe_obj, Giftboxes[gbox][gbox_x], Giftboxes[gbox][gbox_y], Giftboxes[gbox][gbox_z]-0.4, 0.0,0.0,0.0,-1,-1,-1,300.0);
printf("GBOX: %d was activated!", gbox);
}
return 1;
}
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#2
2021-04-15, 08:16 AM (This post was last modified: 2021-04-15, 08:18 AM by Radical.)
Try :

Code:
function:OnLoadGiftboxes()
{
new rows = cache_num_rows();
if(rows)
{
    new iGet[128];
    for(new i; i < rows; i++)
    {
        cache_get_field_content(i, "gbox_x", iGet);
Giftboxes[i][gbox_x] = floatstr(iGet);
        cache_get_field_content(i, "gbox_y", iGet);
Giftboxes[i][gbox_y] = floatstr(iGet);
        cache_get_field_content(i, "gbox_z", iGet);
Giftboxes[i][gbox_z] = floatstr(iGet);
    }
    ActivateGiftboxes(rows);
}
printf("[Debug] Loaded %d/%d giftboxes.", rows, MAX_GIFTBOXES);
return 1;
}



Code:
stock ActivateGiftboxes(ggiftboxes)
{
for(new i; i < ggiftboxes; i++)
{
    new gbox_i = minrand(1, 15);
    new gboxe_obj = 19054;
    if(gbox_i == 1)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 2)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 3)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 4)
    {
        gboxe_obj = 19057;
    }
    if(gbox_i == 5)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 6)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 7)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 8)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 9)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 10)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 11)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 12)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 13)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 14)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 15)
    {
        gboxe_obj = 19058;
    }
    Giftboxes[i][gbox_active] = true;
    Giftboxes[i][gbox_obj] = CreateDynamicObject(gboxe_obj, Giftboxes[i][gbox_x], Giftboxes[i][gbox_y], Giftboxes[i][gbox_z]-0.4, 0.0,0.0,0.0,-1,-1,-1,300.0);
printf("GBOX: %d was activated!", i);
}
return 1;
}
Axitz
Offline

Burgershot Member
Posts: 24
Threads: 11
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#3
2021-04-15, 08:27 AM
(2021-04-15, 08:16 AM)Radical Wrote: Try :

Code:
function:OnLoadGiftboxes()
{
new rows = cache_num_rows();
if(rows)
{
    new iGet[128];
    for(new i; i < rows; i++)
    {
        cache_get_field_content(i, "gbox_x", iGet);
Giftboxes[i][gbox_x] = floatstr(iGet);
        cache_get_field_content(i, "gbox_y", iGet);
Giftboxes[i][gbox_y] = floatstr(iGet);
        cache_get_field_content(i, "gbox_z", iGet);
Giftboxes[i][gbox_z] = floatstr(iGet);
    }
    ActivateGiftboxes(rows);
}
printf("[Debug] Loaded %d/%d giftboxes.", rows, MAX_GIFTBOXES);
return 1;
}



Code:
stock ActivateGiftboxes(ggiftboxes)
{
for(new i; i < ggiftboxes; i++)
{
    new gbox_i = minrand(1, 15);
    new gboxe_obj = 19054;
    if(gbox_i == 1)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 2)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 3)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 4)
    {
        gboxe_obj = 19057;
    }
    if(gbox_i == 5)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 6)
    {
        gboxe_obj = 19054;
    }
    if(gbox_i == 7)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 8)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 9)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 10)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 11)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 12)
    {
        gboxe_obj = 19055;
    }
    if(gbox_i == 13)
    {
        gboxe_obj = 19056;
    }
    if(gbox_i == 14)
    {
        gboxe_obj = 19058;
    }
    if(gbox_i == 15)
    {
        gboxe_obj = 19058;
    }
    Giftboxes[i][gbox_active] = true;
    Giftboxes[i][gbox_obj] = CreateDynamicObject(gboxe_obj, Giftboxes[i][gbox_x], Giftboxes[i][gbox_y], Giftboxes[i][gbox_z]-0.4, 0.0,0.0,0.0,-1,-1,-1,300.0);
printf("GBOX: %d was activated!", i);
}
return 1;
}

Same, doesn't load anything.
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#4
2021-04-15, 08:33 AM (This post was last modified: 2021-04-15, 08:35 AM by Radical.)
Do you call function?

PHP Code:
mysql_tquery(MySQL:1, "SELECT * FROM `table`", "OnLoadGiftboxes", ""); 
Axitz
Offline

Burgershot Member
Posts: 24
Threads: 11
Joined: Apr 2021
Reputation: 0
Location: Malaysia
#5
2021-04-15, 09:39 AM
(2021-04-15, 08:33 AM)Radical Wrote: Do you call function?

PHP Code:
mysql_tquery(MySQL:1, "SELECT * FROM `table`", "OnLoadGiftboxes", ""); 

yes

PHP Code:
#define MAX_GIFTBOXES 100
stock LoadGiftboxes()
{
mysql_pquery(sqldb, "SELECT * FROM giftboxes", "OnLoadGiftboxes");
return 
1;
} 
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode