Re: Gamemode SDK for C/C++ (GDK) -
leonardo1434 - 06.02.2014
I know this topic is about GDK, but this is kinda related to.
I was trying to find out how multidimentional arrays works in the interation pawn/(c++ || c). All i got now, is the code below, which is not working for some reason.
Any help is appreciated,Thanks.
pawn
PHP код:
native Test(string[][],size = sizeof string,size2 = sizeof string[]);
main()
{
new id[2][2];
printf("Pawn");
for(new i = 0; i < sizeof id; ++i)
{
for(new k = 0; k < sizeof id[]; ++k)
{
printf("id[%d][%d]= %d",i,k,k);
id[i][k] = k;
}
}
printf("End Pawn");
Test(id);
}
c++
PHP код:
cell AMX_NATIVE_CALL Test(AMX* amx, cell* params)
{
logprintf((char*)"c++");
cell *addr;
int extra = 4;
amx_GetAddr(amx, params[1], &addr);
for(int i = 0; i < params[2]; i++)
{
for(int k = 0; k < params[3]; ++k)
{
logprintf((char*)"Array[%d]=%d",i, *(addr + extra));
extra += 4;
}
}
logprintf((char*)"End");
return 1;
}
Re: Gamemode SDK for C/C++ (GDK) -
LeaveMe - 06.02.2014
Quote:
Originally Posted by leonardo1434
I know this topic is about GDK, but this is kinda related to.
I was trying to find out how multidimentional arrays works in the interation pawn/(c++ || c). All i got now, is the code below, which is not working for some reason.
Any help is appreciated,Thanks.
|
It's returned as a pointer to first element of array
MyArray = DataType [Row1..Row2][Column1..Column2];
Addr( MyArray, Row, Column) = ((Row2-Row1) * (Column2-Column1)) * SizeOf(DataType) + (Column - Column1) * SizeOf(DataType)
http://en.wikipedia.org/wiki/Array_d...nsional_arrays
Re: Gamemode SDK for C/C++ (GDK) -
leonardo1434 - 06.02.2014
Thank you, LeaveMe. But, i already knew that c/c++ uses row-major order and already tried to make it work, but it won't. That's why in my implementation above, there is a variable named "Extra". I had thought that the interation was something by the size of its cells(4), in some sense, i was in the right path, lol.
Now, i've just find why i was wrong:
Pawn Implementer Guide, page 56/57.
Re: Gamemode SDK for C/C++ (GDK) -
LeaveMe - 12.02.2014
I have reported a small bug on github but since Zeex didn't ave enough time to fix it I'll also post it here.
If you set public hook and Kick or Ban the player then OnPlayerDisconnect is NOT called.
You have to call OnPlayerDisconnect before you do Kick or Ban until the bug is fixed.
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 14.02.2014
Hello!
C + + to write the game mode is the faster it will run as a pawn in?
Respuesta: Gamemode SDK for C/C++ (GDK) -
JustBored - 15.02.2014
A question, version 3.7 works for SA-MP 0.3z? because i want to call a function from it, for example can i do?
pawn Код:
PLUGIN_EXPORT int PLUGIN_CALL OnPlayerWeaponShot(int playerid, int weaponid, int hittype, int hitid, float fx, float fy,float fz)
{
return 1;
}
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 15.02.2014
I would like to ask you a few things have already been written in C + + for game mode!
If you have a lot of cycles, and timing, and is repeated at short intervals, wrote a pawn in game mode is not running at its best.
Now if I am writing in C + + with a game mod, you have several cycles, I use a timer so that it will not lagging?
Re: Gamemode SDK for C/C++ (GDK) -
GWMPT - 15.02.2014
Quote:
Originally Posted by d711728
I would like to ask you a few things have already been written in C + + for game mode!
If you have a lot of cycles, and timing, and is repeated at short intervals, wrote a pawn in game mode is not running at its best.
Now if I am writing in C + + with a game mod, you have several cycles, I use a timer so that it will not lagging?
|
You can use threads.
@By the way, is it my bad, or the binaries aren't yet upgraded of the latest sa-mp release?
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 15.02.2014
Quote:
Originally Posted by Kikito
You can use threads.
|
In simple.
There are many more resources are available to if I am writing in C + + gamemode?
Re: Gamemode SDK for C/C++ (GDK) -
GWMPT - 15.02.2014
Quote:
Originally Posted by d711728
In simple.
There are many more resources are available to if I am writing in C + + gamemode?
|
Yes, definitly.
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 15.02.2014
But there is a big problem.
RAM requirements are very high, you can do something about it?
Re: Gamemode SDK for C/C++ (GDK) -
GWMPT - 15.02.2014
More optimizated the gamemode is, less ram will be used.
Quite simple.
For example: Avoid useless variables.
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 18.02.2014
Before I start to write a letter gamemode more.
How do I have the opportunity to use mysql plugin (maddinat0r r37)?
Where can I find a server that is sure to written in the form of plugin for?
Re: Gamemode SDK for C/C++ (GDK) -
Pupak - 23.02.2014
The best way would be to use
MySQL C/C++ connector instead of the plugin, of course if you're not going to need MySQL in scripts anymore. If you're used to the plugin or you need MySQL in pawn scripts too, you can use sampgdk_invoke_native along with sampgdk_find_native to call plugin's functions.
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 23.02.2014
Quote:
Originally Posted by Pupak
The best way would be to use MySQL C/C++ connector instead of the plugin, of course if you're not going to need MySQL in scripts anymore. If you're used to the plugin or you need MySQL in pawn scripts too, you can use sampgdk_invoke_native along with sampgdk_find_native to call plugin's functions.
|
I see, thank you.
Код:
new query[128];
mysql_format(MySQL, query, sizeof(query), "SELECT * FROM `%s` WHERE `bar` = '%e' AND `foobar` = '%f' LIMIT %d", "foobar", "escape'me\"please", 1.2345, 1337);
// the variable 'query' contains now the formatted query (including the escaped string)
mysql_tquery(MySQL, query, "OnStuffSelected", "");
However, if for example, you would write code similar.
Then the function to call, how to solve?
The "OnStuffSelected" mean.
Respuesta: Gamemode SDK for C/C++ (GDK) -
oOFotherOo - 26.02.2014
The function TogglePlayerSpectating the server crash in OnPlayerConnect, is the 3.7 version SAMPGDK.
Re: Gamemode SDK for C/C++ (GDK) -
[ESC]Walter_Wolf - 02.03.2014
I'm trying to invoke the functions from the MySQL plugin v R6 (G Stylezzzz / madinator), but it seems like I'm missing something. This is my code:
Код:
void mysql_connect(const char* hst, const char* usr, const char* db, const char* pass)
{
return (void)sampgdk_invoke_native(sampgdk_find_native("mysql_connect"), "rrrr", hst, usr, db, pass);
}
now, I am supposed to do something like
Код:
sqlHandler = mysql_connect (SQL_HOST, SQL_DB, SQL_USER, SQL_PASS);
but I don't have the handler type in my "project"
What else do I need? I mean, can I just invoke the plugin's functions, or I need a handler class or something? Is void the correct 'type' for the invoke_native call?
thanks
edit: it compiles even with the crap code I made.
Re: Gamemode SDK for C/C++ (GDK) -
d711728 - 02.03.2014
Quote:
Originally Posted by [ESC]Walter_Wolf
I'm trying to invoke the functions from the MySQL plugin v R6 (G Stylezzzz / madinator), but it seems like I'm missing something. This is my code:
Код:
void mysql_connect(const char* hst, const char* usr, const char* db, const char* pass)
{
return (void)sampgdk_invoke_native(sampgdk_find_native("mysql_connect"), "rrrr", hst, usr, db, pass);
}
now, I am supposed to do something like
Код:
sqlHandler = mysql_connect (SQL_HOST, SQL_DB, SQL_USER, SQL_PASS);
but I don't have the handler type in my "project"
What else do I need? I mean, can I just invoke the plugin's functions, or I need a handler class or something? Is void the correct 'type' for the invoke_native call?
thanks
edit: it compiles even with the crap code I made.
|
I also would be the question of how to handle mysql plugins.
Re: Gamemode SDK for C/C++ (GDK) -
[ESC]Walter_Wolf - 03.03.2014
Re-reading my previous post I realised I didn't quite explain my problem precisely.
The MySQL plugin (v R6) initializes a 'CMySQLHandler' (or similar name) object when the 'mysql_connect' function is called. I can 'sampgdk_find' and 'sampgdk_invoke' the 'mysql.dll' native function in my gamemode plugin, but how do I declare and use the other plugin's class object?
I need the handler for the querries and stuff.
Is it possible?
EDIT: amx_FindPubVar ?
Re: Gamemode SDK for C/C++ (GDK) -
[ESC]Walter_Wolf - 04.03.2014
Thanks a lot Gamer_Z, but I was rethinking the issue, and concluded I don't need the exact address of the class. The fabulous 'sampgdk' finds and calls the (other plugin) desired functions for me, initializes the variables etc.
This is the way I did it:
Код:
cell mysql_connect(string * hst, string * usr, string * db, string * pass)
{
return (cell)sampgdk_invoke_native(sampgdk_find_native("mysql_connect"), "ssss", hst, usr, db, pass);
}
cell mysql_ping(cell *connectionHandle)
{
return (cell) sampgdk_invoke_native(sampgdk_find_native("mysql_ping"), "i", connectionHandle);
}
cell mysql_errno(cell *connectionHandle)
{
return (cell)sampgdk_invoke_native(sampgdk_find_native("mysql_errno"), "i", connectionHandle);
}
Код:
PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
...
cell i;
i = mysql_connect (&SQL_HOST, &SQL_USER, &SQL_DB, &SQL_PASS);
mysql_ping (&i);
if(mysql_errno(&i) == 0) ServerLog::Printf("Connected");
else ServerLog::Printf("Connection failed!");
...
return true;
}
... in case any other noobs like me wish to try it.