SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 03/12/2015, 11:28 AM   #151
SkittlesAreFalling
Big Clucker
 
Join Date: Oct 2013
Posts: 163
Reputation: 14
Default Re: Plugin development guide

http://prntscr.com/99tdsa

Can anyone tell me what is wrong?

VS2015
SkittlesAreFalling is offline   Reply With Quote
Old 03/12/2015, 12:09 PM   #152
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,896
Reputation: 1590
Default Re: Plugin development guide

Try changing the order you include stdlib/stdint and amx.h.
Slice is offline   Reply With Quote
Old 03/12/2015, 12:18 PM   #153
SkittlesAreFalling
Big Clucker
 
Join Date: Oct 2013
Posts: 163
Reputation: 14
Default Re: Plugin development guide

Quote:
Originally Posted by Slice View Post
Try changing the order you include stdlib/stdint and amx.h.
That's funny. Now I only get the last two errors, but I'll keep re-organizing code.
Thank you.
SkittlesAreFalling is offline   Reply With Quote
Old 03/12/2015, 12:37 PM   #154
Neavorce
Big Clucker
 
Neavorce's Avatar
 
Join Date: May 2011
Posts: 81
Reputation: 19
Default Re: Plugin development guide

Add HAVE_STDINT_H preprocessor definition to your project settings and try recompile again.
Neavorce is offline   Reply With Quote
Old 03/12/2015, 12:45 PM   #155
SkittlesAreFalling
Big Clucker
 
Join Date: Oct 2013
Posts: 163
Reputation: 14
Default Re: Plugin development guide

Quote:
Originally Posted by Neavorce View Post
Add HAVE_STDINT_H preprocessor definition to your project settings and try recompile again.
That worked, thank you.
SkittlesAreFalling is offline   Reply With Quote
Old 02/02/2016, 07:45 PM   #156
kurta999
High-roller
 
kurta999's Avatar
 
Join Date: Apr 2009
Location: Slovakia (HU)
Posts: 1,421
Reputation: 626
Default Re: Plugin development guide

It's possible to pass variable by reference to callback?

I would like to do something like this to call a callback from plugin, and get them after function call.

public OnPlayerDoSomething(playerid &param1, &param2, &param3)
{
if(param1 > 10) param1 = 15;
param2 = 0;
return 1;
}
__________________
I don't play and have ANY interest in SA:MP anymore! Please do not ask for help, because I'm not going to reply.
kurta999 is offline   Reply With Quote
Old 02/02/2016, 09:17 PM   #157
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,896
Reputation: 1590
Default Re: Plugin development guide

Of course (that's how strings are passed), just make sure to place them on the heap (unlike some samp callbacks...).
Slice is offline   Reply With Quote
Old 13/02/2016, 04:20 PM   #158
kurta999
High-roller
 
kurta999's Avatar
 
Join Date: Apr 2009
Location: Slovakia (HU)
Posts: 1,421
Reputation: 626
Default Re: Plugin development guide

My dick is out of with this fucking AMX. I've tried to do this what I mentioned before, for first argument it works, but for more not.

My code

Printed result should be:
szőrös fasz 0, 2000

But it:
szőrös fasz 0, 150 <- setting second parameter doesn't work

pawn Code:
void CCallbackManager::OnPlayerClientGameInit(WORD playerid, bool* limitglobalchat, float* globalchatradius, float* nametagdistance, bool* disableenterexits)
{
    int idx = -1;
    cell ret = 1;
    for (std::vector<AMX*>::const_iterator iter = m_vecAMX.begin(); iter != m_vecAMX.end(); ++iter)
    {
        if (!amx_FindPublic(*iter, "OnPlayerClientGameInit", &idx))
        {
            cell addr = NULL, amx_addr, *phys_ptr;
            cell data[2];

            data[0] = static_cast<cell>(*limitglobalchat);
            data[1] = static_cast<cell>(*globalchatradius);

            //data[2] = amx_ftoc(*nametagdistance);
            //data[3] = static_cast<cell>(*disableenterexits);

            amx_PushArray(*iter, &amx_addr, &phys_ptr, data, 2);
            //*globalchatradius = reinterpret_cast<cell*>(phys_ptr);

            //cell limitglobalchat_ = 1;

            //amx_PushArray(*iter, &amx_addr, &phys_ptr, reinterpret_cast<cell*>(&limitglobalchat), 1);


            //amx_PushString(*iter, &addr, NULL, str.c_str(), NULL, NULL);
           
            amx_Push(*iter, static_cast<cell>(playerid));
            amx_Exec(*iter, &ret, idx);
            amx_Release(*iter, amx_addr);

            //*limitglobalchat = !!*phys_ptr;
            logprintf("szőrös fasz %d, %d", phys_ptr[0], phys_ptr[1]);

            //logprintf("globalchat: %d, %f", *limitglobalchat, *globalchatradius);

        }
    }
}

forward OnPlayerClientGameInit(playerid, &limitglobalchat, &globalchatradius);
public OnPlayerClientGameInit(playerid, &limitglobalchat, &globalchatradius)
{
    limitglobalchat = 0;
    globalchatradius = 2000;
//    nametagdistance = -50.2;
  //  disableenterexits = false;
    printf("lófasz - %d", limitglobalchat);
}

Any ideas how to solve this problem?
__________________
I don't play and have ANY interest in SA:MP anymore! Please do not ask for help, because I'm not going to reply.
kurta999 is offline   Reply With Quote
Old 13/02/2016, 04:46 PM   #159
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 869
Reputation: 296
Default Re: Plugin development guide

You should use PushArray with singleton array two times (once for each variable).

PushArray will allocate memory for your 2-element array in the heap. Your callback will receive the 'whole array' in limitglobalradius argument but since its just a reference variable not an array, only the first element of the array which you pushed will be pointed by limitglobalchat.

I don't even know what globalchatradius would be point to. The issue is globalchatradius doesn't take up the 2nd index of the array which you passed because of which you are not getting expected results.

Its intuitive that globalchatradius would be pointing to the very next set of 4 bytes after limitglobalchat. The reference variables are modified using SREF.S ([[FRM + offset]] = PRI). So [[]]? How can you say that the arguments are pointing to cells which are next to each other?

I doubt if using PushArray wiht 2-element array is same as using PushArray twice with singleton array.

I believe this is the way to access the second index of your array using the limitglobalchat argument.
Code:
#emit LOAD.S.pri limitglobalchat
#emit ADD.C 4
#emit MOVE.alt
#emit CONST.pri 2000
#emit STOR.I
But using the globalchatradius argument, I guess the assembly output would be
Code:
#emit CONST.pri 2000
#emit SREF.S.pri globalchatradius
I don't understand what will the globalchatradius be pointing to.
Yashas is offline   Reply With Quote
Old 14/02/2016, 08:47 AM   #160
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 319
Reputation: 382
Default Re: Plugin development guide

You need to call amx_PushArray() twice - first for globalchatradius, then once again for limitglobalchat.

For some reason AMX doesn't have a function for pushing references, only arrays. But references may be thought of as a special case of one-dimensional arrays - they look the same in memory, only difference is the number of elements (i.e. references are 1-element arrays).
xeeZ 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
SA-MP 0.3c in development Kalcor News and Updates 889 19/09/2014 05:39 PM
0.3b Development bar gone WackoX General 94 02/08/2010 11:17 PM
A guide to install Jacob's IRC plugin? Celson Server Support 5 09/06/2009 08:06 AM


All times are GMT. The time now is 01:10 AM.


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