Gamemode with C++
#1

Hi everyone,

i've already asked in the german SAMP-Forum, but here are maybe some more plugin-development-professionals.

I would like to code a Gamemode completely with C++, so i could work with object orientation and classes.
Has anybody here already done something like this, and is this possible and recommendable?

I've heared already about the SAMP-GDK, and read that it's not stable enough. The invoke-method does not seems so easy to me, because i would have to write this code for a simle GetPlayerName:

Code:
g_Invoke->callNative(&PAWN::GetPlayerName, params[1], name);
Maybe someone have some idea.
Thanks.

Sorry for my english!
Reply
#2

I want to write my gamemode in C, planning it for 2 weeks, but I haven't fully decided. I want to know, will it have better performance? And why samp gdk is unstable? Does invoke works with custom functions? Great to hear I'm not alone having this idea.
Reply
#3

You can easly code a half of the gamemode on pawn, and the other half on the plugin.

Example:
pawn Code:
stock GetPlayerName(playerid)
{
      PLUGIN_GetPlayerName(playerid);
}
then, on the plugin side, you script the function "PLUGIN_GetPlayerName" with the sampgdk or the plugin sdk.

OR, you hook the callbacks and do the code on it
Reply
#4

In the german forum someone said, that it won't have better performance, because the plugin will call the samp native functions, so at the end you have the speed from PAWN + the speed for C++.
Sounds correctly, but i don't know if it's true.

I don't know if samp-gdk is really unstable, but i read here that it has bugs, especially on linux-servers. The GPS-Plugin from Gamer_Z for example had some bugs after updating to some version of samp-gdk.
And i've read something about, that you can't run 2 plugins at the same time with samp-gdk, because they would mess around with eatch other.
So for me, it sounds like it isn't really the best solution.

I hope some of the professionals have some idea for our plans!
Reply
#5

Quote:
Originally Posted by Nikolas-Mrak
View Post
In the german forum someone said, that it won't have better performance, because the plugin will call the samp native functions, so at the end you have the speed from PAWN + the speed for C++.
Sounds correctly, but i don't know if it's true.

I don't know if samp-gdk is really unstable, but i read here that it has bugs, especially on linux-servers. The GPS-Plugin from Gamer_Z for example had some bugs after updating to some version of samp-gdk.
And i've read something about, that you can't run 2 plugins at the same time with samp-gdk, because they would mess around with eatch other.
So for me, it sounds like it isn't really the best solution.

I hope some of the professionals have some idea for our plans!
Read my post again:
then, on the plugin side, you script the function "PLUGIN_GetPlayerName" with the sampgdk or the plugin sdk.

For some people. sampgdk is better, for other, is the plugin sdk(I use the plugin sdk).
I just gave you some instructions of how you could do your gamemode.

Now, you just select your way of doing the things.

Good luck
Reply
#6

My idea for doing this is the advantage of using classes and doing stuff object oriented, because in PAWN you can't do things like this. You have to write thousends of lines in one file, and in my view thats a mess in big scripts.

It would be perfect if a c++ gamemode would run the same speed as a pawn-script.
Reply
#7

There should be some slight speed gain by using C++ because AFAIK in samp-gdk, when calling native, samp-gdk hooks amx_Register and intercepts all the natives so you have a direct access to that function, only thing that goes through Pawn VM is the code inside the actual native you called...
Reply
#8

Quote:
Originally Posted by Y_Less
View Post
Or jsut use multiple files like most people.
I've tested this some time ago, but the problem is that you can't use variables trough multiple files. Or is there a way?
Reply
#9

You mean, i could use getter/setter in PAWN? Haven't tried this so far.. But this would be awesome.
Reply
#10

Quote:
Originally Posted by Nikolas-Mrak
View Post
I would like to code a Gamemode completely with C++, so i could work with object orientation and classes.
Has anybody here already done something like this, and is this possible and recommendable?
It is possible. If you are familiar with C++ you can easily create a (almost) clean OO gamemode. The GDK is your only chance to do that.

Quote:

I've heared already about the SAMP-GDK, and read that it's not stable enough.

Yes, the current version is bugged, but zeex is improving it continuously. I'm currently using v3.0.2 and have no problems with it. I couldn't test it on a Linux system, so I can't say much about that.

I'm currently working on such a gamemode and I think it has far more advantages than Pawn. Even if it should be slower than native Pawn, it's worth that.

And sorry for my English, I'm German too.
Reply
#11

Quote:
Originally Posted by Pain123
View Post
It is possible. If you are familiar with C++ you can easily create a (almost) clean OO gamemode. The GDK is your only chance to do that.
Erm I just needed the GetPlayerPos function and it's actually easy to call it from a plugin WITHOUT sampgdk or invoke. (however it's an ugly as f*ck hack and I didn't measure how much slower/faster it is than calling from pawn)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)