SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 27/11/2018, 09:57 AM   #11
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 337
Reputation: 255
Default Re: PawnScraper

Quote:
Originally Posted by fiki574 View Post
Nice work!

However, is there any way to send a HTTP request towards the SAMP server instead of only external URLs?
How are you supposed to send an HTTP requrest to a SA-MP server? You may try HttpGet("http://localhost"); if you have something listening on HTTP there.

Anyway, how does this plugin handle cleanup of created objects (responses, selectors etc.)?
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
 i_quat.inc 


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline   Reply With Quote
Old 27/11/2018, 10:36 AM   #12
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,951
Reputation: 497
Post Re: PawnScraper

Quote:
Originally Posted by IllidanS4 View Post
Anyway, how does this plugin handle cleanup of created objects (responses, selectors etc.)?
Clean up is done through "Delete" functions. Its automatically called when created variable get out of scope through destructors. But they won't work in cases having global and static lifetime. Users have to call these functions manually in those cases.
SyS is offline   Reply With Quote
Old 27/11/2018, 12:15 PM   #13
fiki574
Gangsta
 
fiki574's Avatar
 
Join Date: Mar 2011
Location: Croatia
Posts: 849
Reputation: 169
Default Re: PawnScraper

Quote:
Originally Posted by IllidanS4 View Post
How are you supposed to send an HTTP requrest to a SA-MP server? You may try HttpGet("http://localhost"); if you have something listening on HTTP there.
Maybe this plugin has an implementation for starting a HTTP listener with the SAMP server, so I could (for example) send GET requests from an external app towards that listener and parse some in-game stuff I want to the response.
__________________
fiki574 is offline   Reply With Quote
Old 27/11/2018, 12:18 PM   #14
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,951
Reputation: 497
Default Re: PawnScraper

Quote:
Originally Posted by fiki574 View Post
Maybe this plugin has an implementation for starting a HTTP listener with the SAMP server, so I could (for example) send GET requests from an external app towards that listener and parse some in-game stuff I want to the response.
That's not what this plugin is about...
SyS is offline   Reply With Quote
Old 27/11/2018, 01:13 PM   #15
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 337
Reputation: 255
Default Re: PawnScraper

Quote:
Originally Posted by SyS View Post
Clean up is done through "Delete" functions. Its automatically called when created variable get out of scope through destructors. But they won't work in cases having global and static lifetime. Users have to call these functions manually in those cases.
I am not sure using a destructor is safe in this case. First, you ignore the size parameter, so arrays of these objects will not be destroyed properly. Second, imagine this code:
pawn Code:
new Response:globalResp;

main()
{
    new Response:resp = HttpGet("https://wiki.sa-mp.com");
    if(...)
    {
        globalResp = resp;
    }
}
When resp goes out of scope, globalResp will become invalid as well (and could potentially refer to a completely different response after a while, depending on your implementation).
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
 i_quat.inc 


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline   Reply With Quote
Old 27/11/2018, 01:17 PM   #16
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,951
Reputation: 497
Default Re: PawnScraper

Quote:
Originally Posted by IllidanS4 View Post
I am not sure using a destructor is safe in this case. First, you ignore the size parameter, so arrays of these objects will not be destroyed properly. Second, imagine this code:
pawn Code:
new Response:globalResp;

main()
{
    new Response:resp = HttpGet("https://wiki.sa-mp.com");
    if(...)
    {
        globalResp = resp;
    }
}
When resp goes out of scope, globalResp will become invalid as well (and could potentially refer to a completely different response after a while, depending on your implementation).
Yes you are right that will result in fault. I think I should change my approach then.Something like borrow check or overload = operator to make a clone. I don't know whether either of is possible though
SyS is offline   Reply With Quote
Old 27/11/2018, 02:07 PM   #17
fiki574
Gangsta
 
fiki574's Avatar
 
Join Date: Mar 2011
Location: Croatia
Posts: 849
Reputation: 169
Default Re: PawnScraper

Quote:
Originally Posted by SyS View Post
That's not what this plugin is about...
That's why I was asking this question

Thanks for clearance
__________________
fiki574 is offline   Reply With Quote
Old 27/11/2018, 10:14 PM   #18
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 337
Reputation: 255
Default Re: PawnScraper

Quote:
Originally Posted by SyS View Post
Yes you are right that will result in fault. I think I should change my approach then.Something like borrow check or overload = operator to make a clone. I don't know whether either of is possible though
Not possible, as far as I know. ****** tried to implement reference counting via destructors, but currently, = cannot be sufficiently overloaded in this way. I'd suggest not using destructors at all; people are used to cleaning stuff anyway.
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
 i_quat.inc 


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline   Reply With Quote
Old 27/11/2018, 11:33 PM   #19
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,951
Reputation: 497
Default Re: PawnScraper

Quote:
Originally Posted by IllidanS4 View Post
Not possible, as far as I know. ****** tried to implement reference counting via destructors, but currently, = cannot be sufficiently overloaded in this way. I'd suggest not using destructors at all; people are used to cleaning stuff anyway.
Thanks for the advice .
SyS is offline   Reply With Quote
Old 01/12/2018, 12:17 PM   #20
fordawinzz
Huge Clucker
 
Join Date: Jun 2011
Posts: 445
Reputation: 35
Default Re: PawnScraper

Can I get data from a tag that 'has' a class, like:
Code:
<span class="some_class_here">data_i_want_to_get</span>
using this plugin?

I'm not into HTML parsing so I don't know yet how to work with this. Thank you.
fordawinzz 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



All times are GMT. The time now is 12:09 PM.


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