Any tutorials for multi-threading?
#1

Hello,

I have used a bit of multi-threading in Java before but only when i was messing around with it. I dont really know 100% how multi-threading works, all i know is that it lets you do more things at once, and this will make your server run a lot faster...so less lag with the script...

https://sampforum.blast.hk/showthread.php?tid=108781

Thats the plugin i came across, its the one by ******..

So is there any tutorials on this? (or even any C++ tutorials on multi-threading that will help me grasp the Pawn multi-threading... I have basic knowledge of C++ and even have book to help me if i get stuck...)..

So, mainly pawn tutorials if there is any! thanks!
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=128338

Quote:

This is my response to someone who messaged me about posting a memory hacking server plugin. The explanation for why we don't allow it isn't simple.

Quote:
Can i create topic about Structure Access plugin in plugins forum ?


In short, no.

At present, information contained in the SA-MP server structures are designed to be accessed using pawn, not by peeking and poking the server memory.

Plugins are designed to extend pawn. If there is information that cannot be accessed by scripting, people should request it added to SA-MP's pawn scripting natives. I'm positive 90% of the information held by the server can already be accessed using pawn.

Memory addresses and structures within the SA-MP server change with every release, pawn natives do not. If a plugin is coded to access specific memory addresses, backward compatibility for server owners will be broken with every server update.

There are variables that we do not want the server owners tampering with; such as the amount of players on the server, version information, and read-only console variables. Servers that fake this information end up being blocked from the server lists and it costs us time researching whether these servers are breaking the rules (not fun).

This might change in future versions and plugins might be given direct access to some of the structures/classes. However, SA-MP is not designed to be 100% extensible. There seems to be a lot of confusion on this subject. SA-MP is designed to be largely configurable by server owners while still making the game moderately consistent for the players across different servers. That means, first and foremost, SA-MP is still a multiplayer extension for GTA: San Andreas. It doesn't pretend to be its own game engine.

Quote:
What about hooking to callbacks(such as used by ****** in Multithread). Such option must be implented either by hooking or providing additional function in SDK.


Pawn is not threadsafe. The only way to interact with pawn from threads is to implement a ProcessTick function. If you start dealing with pawn from a thread that isn't synchronised with the server's main loop, it's likely you'll be calling in to it at a time when it's already doing something else.

Callbacks are not designed to be hooked or used in plugins. The plugins provide functionality to the pawn script, they're not designed for gamemode related code which the callbacks are intended. If you did need access to a callback from the plugin, you could have a script (probably filterscript) call a plugin function when it receives the callback. This is a much cleaner way than trying to hack memory addresses.

Reply
#3

Gotcha!! Any C++ tutorials you know off anyway? Only if you already know some good ones..

---

ALSO, off topic:

Can you do a for loop like this and would it be better than declaring new i; in every for loop?

pawn Код:
//at top
new i;

for(i =0; i<NUMBER; i++){
//code
}

ALSO..

to make plugins, can i just use C++?? or do i need to know C?
Reply
#4

Quote:
Originally Posted by DarrenReeder
Посмотреть сообщение
Gotcha!! Any C++ tutorials you know off anyway? Only if you already know some good ones..

---

ALSO, off topic:

Can you do a for loop like this and would it be better than declaring new i; in every for loop?

pawn Код:
//at top
new i;

for(i =0; i<NUMBER; i++){
//code
}

ALSO..

to make plugins, can i just use C++?? or do i need to know C?
Correct me if I'm wrong, but this means that only 1 loop can run at any one point, or they will screw up...

In other words, no, you can't do that.
Reply
#5

define it:

pawn Код:
#define ForLoop(%0,%1) \
     for(new %0; %0 < %1; %0++)
Reply
#6

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
define it:

pawn Код:
#define LOOP_AMOUNT 100
#define ForLoop(%0) \
     for(new %0; %0 < LOOP_AMOUNT; %0++)
Erm, wouldn't this be easier?

pawn Код:
#define ForLoop(%0,%1) \
     for(new %0; %0 < %1; %0++)
I guess you can type the number you want now. So if you want a playerloop , then just

pawn Код:
ForLoop(i, MAX_PLAYERS)
didnt test it, just were in my mind.
Reply
#7

pawn Код:
foreach ( Player , i )
Reply
#8

i dont use foreach
Reply
#9

Quote:
Originally Posted by CrucixTM
Посмотреть сообщение
Correct me if I'm wrong, but this means that only 1 loop can run at any one point, or they will screw up...

In other words, no, you can't do that.
It only does 1 loop at a time anyway?? its single threaded?
Reply
#10

Quote:
Originally Posted by Niixie
Посмотреть сообщение
Erm, wouldn't this be easier?

pawn Код:
#define ForLoop(%0,%1) \
     for(new %0; %0 < %1; %0++)
I guess you can type the number you want now. So if you want a playerloop , then just

pawn Код:
ForLoop(i, MAX_PLAYERS)
didnt test it, just were in my mind.
Yeah i thought i would update my post, i didn't think of it in an hurry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)