SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 15/06/2018, 05:51 AM   #1
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 111
Reputation: 7
Default #emit crash

Why does this works
PHP Code:
main()
{
    new 
t;

    
#emit LOAD.S.pri    t
    #emit PUSH.pri

    #emit PUSH.C         4
    #emit SYSREQ.C         SetWorldTime

    #emit LCTRL         4
    #emit LOAD.S.alt     8
    #emit ADD
    #emit SCTRL         4

But changing this line
PHP Code:
new t
to this
PHP Code:
new 19
doesn't work and shows this:
Quote:
[debug] Run time error 6: "Invalid instruction"
[debug] Unknown opcode 0x1300 at address 0x00000013
[debug] AMX backtrace:
[debug] #0 00000013 in main () from <unknown>
Script[gamemodes/z/t.amx]: Run time error 6: "Invalid instruction"
What opcode should I use to pass the var?
GaByM is offline   Reply With Quote
Old 15/06/2018, 09:28 AM   #2
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,729
Reputation: 3073
Default Re: #emit crash

Why are you writing this in assembly? What are you trying to achieve? For the vast majority of cases you just don't need this, and there is very little support if you don't know what you're doing.

AFAIK, this is the only documentation on the subject. If that doesn't help, you're pretty much on your own I'm afraid, it's well outside the scope of normal scripting:

https://github.com/YashasSamaga/AMX-Assembly-Docs
Y_Less is offline   Reply With Quote
Old 15/06/2018, 10:23 AM   #3
CodeStyle175
Huge Clucker
 
CodeStyle175's Avatar
 
Join Date: Apr 2014
Posts: 358
Reputation: 34
Default Re: #emit crash

You don't even need to know emit for writing simple gamemode, just make every system simple and working. Only usage for emit is formated send client messages what saves you code writing time.

Last edited by CodeStyle175; 15/06/2018 at 05:47 PM.
CodeStyle175 is offline   Reply With Quote
Old 15/06/2018, 10:50 AM   #4
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,729
Reputation: 3073
Default Re: #emit crash

You don't even need emit for that any more:

PHP Code:
SendMessage(playeridfmt[], ...)
{
    new 
dest[144];
    
format(destsizeof (dest), fmt___(2));
    
SendClientMessage(playeridCOLOUR_REDdest);

Assembly shouldn't be needed now unless you're writing VERY low-level stuff that modifies the language itself.
Y_Less is offline   Reply With Quote
Old 17/06/2018, 10:17 AM   #5
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 111
Reputation: 7
Default Re: #emit crash

On short: I'm trying to call format with variables from an array (and it's not working so I tried somthing smaller)

Long story:

Problem: Loading player's data from multiple DB tables across multiple files in my GM
Fix: Create a file named load with a single big query
Problem 2: There is quite a bit of data to load + this means I have to split my systems (load part will be ripped off)
Fix 2: A callback through all files. Each system send it's query to the DB (note that I need a counter to know when everything loaded).

This is the method I'm using right now and I want to change it. Why? Take a look at how it works https://pastebin.com/Pbzi2eWp

There is too much code I need to repeat every time + there are too many callbacks regarding the login system
(I have OnPlayerLoad which is called just to format the queries and then call other callback to load the data;
OnAccountLoad which is the callback from this query "SELECT * FROM users WHERE id=x";
OnUserFound which load basic things such as the player ID from 'names' table (yes, I have a names table),
the admin level in case the server is open just for admins and the ban status (don't load anything until I check those))
and I try to reduce this number.

Fix: Have a string which contains the model of all the queries (like this: "SELECT * FROM users WHERE id=%i; SELECT admin FROM admins WHERE id=%i; SELECT ..")
Each system calls a function which concatenate their query to the string (under OnGameModeInit). When the palyer's data can be loaded,
format the query and send it. Now I don't know how to format the query: https://pastebin.com/Q42Ra7qn
GaByM is offline   Reply With Quote
Old 17/06/2018, 12:50 PM   #6
Calisthenics
Big Clucker
 
Join Date: May 2018
Posts: 56
Reputation: 4
Default Re: #emit crash

If I were you, I'd load the very basics (main table and admins table) and all the rest should be loaded with a delay unless it's necessary upon logging in to do something with these values (in example, spawning to previous location).

Now there are some ideas I can think of, such as JOINs, multi-statements (R40 version and above) and storing the cache.
Calisthenics is offline   Reply With Quote
Old 17/06/2018, 12:56 PM   #7
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,729
Reputation: 3073
Default Re: #emit crash

This sounds like an issue with a poorly designed database schema, more than a problem with emit. But it sounds like you just need a loop:

PHP Code:
strcat(queryFunctions[i]); // Why does that start with an upper-case letter? 
Y_Less 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
#emit, What's it? SystemX Scripting Help 3 22/01/2016 04:44 PM
[Tutorial] #emit Misiur Tutorials 2 11/11/2015 03:34 AM
when should #emit be used sammp Scripting Help 3 15/11/2014 09:49 AM
#emit rVar Scripting Help 3 08/09/2012 06:26 PM
#emit Max_Coldheart Scripting Help 6 08/03/2012 08:17 PM


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


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