SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/04/2020, 11:54 AM   #1
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Basebuilding problem (streamer/dynamicobjects)

Hi everyone,

A good while ago i've written a basebuilding system and it was working perfect, now I am trying to implent factions to work with basebuilding too. The problem here is that, it just doesn't do anything. No object is created, no query is getting executed. But the printf's are correct and if I manually enter the query it even works. What could be going on here?

Server log:
Code:
[13:51:48] CreateDynamicObject(19641, -296.496551, 1871.890502, 42.289062, 0.000000, 0.000000, 0.000000, 0, 0);
[13:51:48] INSERT INTO `BASEOBJECTS` (`ID`, `TID`, `POSX`, `POSY`, `POSZ`, `ROTX`, `ROTY`, `ROTZ`, `WORLD`, `INTERIOR`, `MODELID`) VALUES('5', '2', '-296.496551', '1871.890502', '42.289062', '0', '0', '0', '0', '0', '19641')
No object is added and the query also is not getting executed. When I copy paste the query it works.

My code:
PHP Code:
NewBaseItem(playeridmodelidbool:duplicateobjectid)
{
    new 
        
DBResult:RESULT
        
szQuery[364], 
        
idworldinteriortid=GetPlayerTerritoryID(playerid),
        
FloatxFloatyFloatzFloatrx=0Floatry=0Floatrz=0
    
;

    
SetPVarInt(playerid"is_using_textdraw"0);
    
HideInventory(playerid);

    
RESULT db_query(ZARP_DATABASE"SELECT * FROM `BASEOBJECTS` ORDER BY ID DESC");
    if(
db_num_rows(RESULT))
    {
        
id=db_get_field_assoc_int(RESULT"ID");
        
id+=1// get the next row id manually so i can add it to an enum later
    
} else id=1;
    
db_free_result(RESULT);

    if(
id >= MAX_BASE) return SendSplitMessage(playerid,GREY,"ERROR: Max amount of base objects reached.");

    
ABase[playerid]=1;
    
world GetPlayerVirtualWorld(playerid);
    
interior GetPlayerInterior(playerid);

    if(!
duplicate)
    {
        
GetPlayerPos(playerid,x,y,z);
        
x-=2.0;
        
y-=2.0;
    }
     else 
GetBaseObjectPos(objectidx,y,z,rx,ry,rz);

    
BaseObject[tid][id] = CreateDynamicObject(modelidxyzrxryrzworldinterior);
    
printf("CreateDynamicObject(%d, %f, %f, %f, %f, %f, %f, %d, %d);"
        
modelidxyzrxryrzworldinterior);
    
Streamer_Update(playerid);

    
format(szQuerysizeof(szQuery),
    
"INSERT INTO `BASEOBJECTS` (`ID`, `TID`, `POSX`, `POSY`, `POSZ`, `ROTX`, `ROTY`, `ROTZ`, `WORLD`, `INTERIOR`, `MODELID`) VALUES('%d', '%d', '%f', '%f', '%f', '0', '0', '0', '%d', '%d', '%d')",
    
idtidxyzworldinteriormodelid);
    
db_query(ZARP_DATABASEszQuery);
    
printf(szQuery);

    
EditDynamicObject(playeridBaseObject[tid][id]);
    
SelectedObject[playerid]=id;
    return 
1;

Any help would be appreciated.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 12/04/2020, 12:16 PM   #2
YouShootIDodge
Big Clucker
 
Join Date: May 2019
Posts: 65
Reputation: 14
Default Re: Basebuilding problem (streamer/dynamicobjects)

Object limit has been reached?
YouShootIDodge is offline   Reply With Quote
Old 12/04/2020, 12:19 PM   #3
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Re: Basebuilding problem (streamer/dynamicobjects)

It has not, I have other systems that use the same method and still work. Also, when I add the query manually to the database and restart the server, the object is there and I can even edit it.

Also I'm not aware of any object limits for streamer plugin.

Screenshot:
https://cdn.discordapp.com/attachmen...86/unknown.png

Edit:
I just found out that duplicating the object works (When bool duplicate is true), and that uses the same function.
What could be going on here?

I am really confused now...
PHP Code:
if(duplicate// Literally only works if bool is set to 1. However, it still prints everything fine. This is so weird.. 
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website

Last edited by jasperschellekens; 12/04/2020 at 03:40 PM.
jasperschellekens is offline   Reply With Quote
Old 13/04/2020, 06:43 AM   #4
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Re: Basebuilding problem (streamer/dynamicobjects)

bump
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 13/04/2020, 12:36 PM   #5
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 836
Reputation: 52
Default Re: Basebuilding problem (streamer/dynamicobjects)

logs and mysql logs are fine? i doubt it.
__________________
JasonRiggs is offline   Reply With Quote
Old 13/04/2020, 12:37 PM   #6
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Re: Basebuilding problem (streamer/dynamicobjects)

Quote:
Originally Posted by JasonRiggs View Post
logs and mysql logs are fine? i doubt it.
Oh they are. No error is shown anywhere. I don't even use mysql but yes all the logs are fine.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 13/04/2020, 12:39 PM   #7
TheLeech
Banned
 
Join Date: Aug 2015
Location: Under your bed
Posts: 188
Reputation: 6
Default Re: Basebuilding problem (streamer/dynamicobjects)

I had this issue with my furniture system, Is everything in the query spelt the right way as in the database, Like Capitalized correctly etc? My issue was due to ID not being capalized in my query.
TheLeech is offline   Reply With Quote
Old 13/04/2020, 12:43 PM   #8
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Re: Basebuilding problem (streamer/dynamicobjects)

Quote:
Originally Posted by TheLeech View Post
I had this issue with my furniture system, Is everything in the query spelt the right way as in the database, Like Capitalized correctly etc? My issue was due to ID not being capalized in my query.
Everything is in the correct case. When I paste the query that the script prints with printf , manually into phpliteadmin it works.
I also have to add that duplicating an object works just fine, using the exact same function, only changing the bool duplicate to true.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 13/04/2020, 03:17 PM   #9
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,126
Reputation: 527
Default Re: Basebuilding problem (streamer/dynamicobjects)

Can we see where you're calling the function?

I have a feeling GetBaseObjectPos is just giving you the wrong coordinates, and the object is being created, just not in the right place.

Also for queries, I wouldn't wrap your integer or float values in parentheses. Just input them as they are.

So instead of ('%d', '%f', '%f'), do (%d, %f, %f). The parentheses are normally only used for strings.
__________________


Kar's Cops and Robbers 2020
Threshold is offline   Reply With Quote
Old 13/04/2020, 03:51 PM   #10
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,070
Reputation: 106
Default Re: Basebuilding problem (streamer/dynamicobjects)

Actually when GetBaseObjectPos is used to spawn the object, it works. It just doesn't work when I use the player position to spawn it.

PHP Code:
if(!duplicate// function does not work
    
{
        
GetPlayerPos(playerid,x,y,z);
        
x-=2.0;
        
y-=2.0;
    }
     else 
GetBaseObjectPos(objectidx,y,z,rx,ry,rz); // Function works if duplicate 
Here is my GetBaseObjectPos function:
PHP Code:
Float:GetBaseObjectPos(id, &Float:PosX, &Float:PosY, &Float:PosZ, &Float:RotX, &Float:RotY, &Float:RotZ)
{
    new 
DBResult:RESULTszQuery[128];
     
format(szQuerysizeof(szQuery), "SELECT * FROM `BASEOBJECTS` WHERE `ID` = '%d'"id);
    
RESULT db_query(ZARP_DATABASEszQuery);
    if(
db_num_rows(RESULT))
    {
        
PosX=db_get_field_assoc_float(RESULT,"POSX");
        
PosY=db_get_field_assoc_float(RESULT,"POSY");
        
PosZ=db_get_field_assoc_float(RESULT,"POSZ");
        
RotX=db_get_field_assoc_float(RESULT,"ROTX");
        
RotY=db_get_field_assoc_float(RESULT,"ROTY");
        
RotZ=db_get_field_assoc_float(RESULT,"ROTZ");
    }

So the function is getting called from two different places.
- Use item part which detects if the item is a basebuilding object.
PHP Code:
if(IsItemBaseObject(modelid)) return NewBaseItem(playeridmodelidfalse0); 
-Command /editbaseobject [ID]
Player will select edit from a dialog list and this is it's response:
PHP Code:
case 1:{
                    if(!
DoesPlayerHaveItem(playerid,modelid)) return SendSplitMessage(playeridGREY"ERROR: You don't have the required item(s) to duplicate this object.");
                    
format(logstr,sizeof(logstr),"is duplicating base object with ID %i",id);
                    
NewBaseItem(playeridmodelidtrueid);
                } 
This is really driving me nuts.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens 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
Rendering DynamicObjects Problem MaestrulFritz Scripting Help 1 20/01/2019 02:04 PM
Help with dynamicobjects ServerScripter Scripting Help 18 23/09/2011 11:40 AM
DynamicObjects Twyke Help Archive 3 02/04/2009 11:22 AM


All times are GMT. The time now is 03:08 AM.


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