SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/08/2019, 11:14 PM   #1
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 80
Reputation: 0
Default Pawno compiling ignore a public

Hi guys, Im trying to make an ATM system for my RP server, but I have just a little problem...When the compiling try to load the public, the pawno compiling just ignore it (Im using sublime text 3)


pawn Code:
// OnGameModeInIt
mysql_tquery(g_SQL, "SELECT * FROM `atms`", "LoadAtms");

I've found the problem but I don't know how to solve, because I need the objectid

If i use that, the script will ignore it (the public loadatm)
pawn Code:
new ATMSPAWNED = AtmData[ATMSPAWNED][atmObject] = CreateDynamicObject(19324, AtmData[id][atmX], AtmData[id][atmY], AtmData[id][atmZ], AtmData[id][atmRX], AtmData[id][atmRY], AtmData[id][atmRZ], 0, 0, -1, 200.0);

but if I try that, the script can load the public and create all the saved ATMs, but the code didn't set the ID
pawn Code:
new ATMSPAWNED;
AtmData[ATMSPAWNED][atmObject] = CreateDynamicObject(19324, AtmData[id][atmX], AtmData[id][atmY], AtmData[id][atmZ], AtmData[id][atmRX], AtmData[id][atmRY], AtmData[id][atmRZ], 0, 0, -1, 200.0);
how can I solve that? thanks
OuDayas is offline   Reply With Quote
Old 15/08/2019, 03:51 AM   #2
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,819
Reputation: 650
Default Re: Pawno compiling ignore a public

Well, that line makes no sense, tell me what is the result of this
pawn Code:
new var = var;
You don't know, neither do I, although this snippet will work yours won't because you do
pawn Code:
new ATMSPAWNED = AtmData[ATMSPAWNED][atmObject] = ...
Which probably will yield an invalid array access, thus stopping the execution, try to run the CrashDetect plugin
Your second version does work because the first line assigns 0 to ATMSPAWNED and that is a valid index


additional notes
  • why are you saving the position and rotatation?, you could use GetDynamicObjectPos/Rot
  • you never check if the id returned by CreateDynamicObject is an valid index
  • why is id static?
  • you never check if the object / label exist in the delete loop
  • why do you use GetATM_FreeSlot if you just deleted everything, use an incrementing variable
  • GetATM_FreeSlot returns 1 instead of -1
Nero_3D is online now   Reply With Quote
Old 15/08/2019, 05:31 PM   #3
OuDayas
Big Clucker
 
Join Date: Jan 2019
Posts: 80
Reputation: 0
Default Re: Pawno compiling ignore a public

Quote:
Originally Posted by Nero_3D View Post
Well, that line makes no sense, tell me what is the result of this
pawn Code:
new var = var;
You don't know, neither do I, although this snippet will work yours won't because you do
pawn Code:
new ATMSPAWNED = AtmData[ATMSPAWNED][atmObject] = ...
Which probably will yield an invalid array access, thus stopping the execution, try to run the CrashDetect plugin
Your second version does work because the first line assigns 0 to ATMSPAWNED and that is a valid index


additional notes
  • why are you saving the position and rotatation?, you could use GetDynamicObjectPos/Rot
  • you never check if the id returned by CreateDynamicObject is an valid index
  • why is id static?
  • you never check if the object / label exist in the delete loop
  • why do you use GetATM_FreeSlot if you just deleted everything, use an incrementing variable
  • GetATM_FreeSlot returns 1 instead of -1
then, how can i solve it?
OuDayas is offline   Reply With Quote
Old 15/08/2019, 09:13 PM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,819
Reputation: 650
Default Re: Pawno compiling ignore a public

Quote:
Originally Posted by OuDayas View Post
then, how can i solve it?
You probably wanted to store the objectid in atmObject
pawn Code:
new ATMSPAWNED = CreateDynamicObject(...
AtmData[ATMSPAWNED][atmObject] = ATMSPAWNED;
but there is no reason to do so if you use the objectid as index
Nero_3D is online now   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
Pawno not compiling my GM Boss201 Server Support 11 25/07/2016 05:14 PM
Pawno crashes on compiling? Mado Scripting Help 7 15/12/2012 07:50 AM
[Help]Compiling with Pawno str33tpunk Help Archive 7 09/07/2010 01:15 PM
I need some help regarding Pawno Compiling. Wolfgames Help Archive 1 24/01/2010 05:08 AM
Compiling with Pawno Weed_ Help Archive 7 15/03/2009 10:29 AM


All times are GMT. The time now is 01:05 PM.


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