Some errors related to SA-MP GDK
#1

Can someone help me figuring out this error?

Error Code:
pawn Код:
Warning 1   warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.  c:\Documents and Settings\TopAz\My Documents\Visual Studio 2010\Projects\myfirstplugin\myfirstplugin\myfirstplugin.cpp  65  1   myfirstplugin
Error   2   error C2664: 'GetPlayerPos' : cannot convert parameter 2 from 'float' to 'float *'  c:\Documents and Settings\TopAz\My Documents\Visual Studio 2010\Projects\myfirstplugin\myfirstplugin\myfirstplugin.cpp  71  1   myfirstplugin
    3   IntelliSense: argument of type "float" is incompatible with parameter of type "float *" c:\documents and settings\topaz\my documents\visual studio 2010\projects\myfirstplugin\myfirstplugin\myfirstplugin.cpp  71  26  myfirstplugin
    4   IntelliSense: argument of type "float" is incompatible with parameter of type "float *" c:\documents and settings\topaz\my documents\visual studio 2010\projects\myfirstplugin\myfirstplugin\myfirstplugin.cpp  71  29  myfirstplugin
    5   IntelliSense: argument of type "float" is incompatible with parameter of type "float *" c:\documents and settings\topaz\my documents\visual studio 2010\projects\myfirstplugin\myfirstplugin\myfirstplugin.cpp  71  32  myfirstplugin
Error Lines:
pawn Код:
65: std::sprintf(message, "Hello, %s!", name);
71: GetPlayerPos(playerid, x, y, z);
Reply
#2

Is it proper to use

pawn Код:
float* x;
float* y;
float* z;
Instead of

pawn Код:
float x;
float y;
float z;
because if I use float* instead of float, then there is no error.
Reply
#3

About the sprintf, which kind of variables are 'message' and 'name' that you are using ? 'char*' 'char' , 'string' ?

As for the GetPlayerPos , well as long as it works I think there's no problem..

Edit: Just tested the GetPlayerPos and it works the way you wrote... maybe it could be caused by some update on the sampGDK... ( Im using a quite old version.. )

Here's how I tested
pawn Код:
float x;
float y;
float z;
GetPlayerPos ( ( int )params [ 1 ] , x , y , z ) ;
Reply
#4

Quote:
Originally Posted by SlashPT
Посмотреть сообщение
About the sprintf, which kind of variables are 'message' and 'name' that you are using ? 'char*' 'char' , 'string' ?

As for the GetPlayerPos , well as long as it works I think there's no problem..

Edit: Just tested the GetPlayerPos and it works the way you wrote... maybe it could be caused by some update on the sampGDK... ( Im using a quite old version.. )

Here's how I tested
pawn Код:
float x;
float y;
float z;
GetPlayerPos ( ( int )params [ 1 ] , x , y , z ) ;
ahhh maybe. But I am not able to compile it. I think I am missing a library.

Here is the error

Код:
Error	51	error LNK1120: 50 unresolved externals	c:\documents and settings\topaz\my documents\visual studio 2010\Projects\accountsystem\Debug\accountsystem.dll	accountsystem
I have made a module definition file and link it with the project but still getting that error.
Reply
#5

I think that you have that include this on project by clicking with the right mouse button in your project and adding on the right place(usually in Headers Files).

Reply
#6

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
I think that you have that include this on project by clicking with the right mouse button in your project and adding on the right place(usually in Headers Files).

Thank you very much CyNic. You deserve reputation!
Reply
#7

I don't know how you code but the way i avoid the float problem is:
pawn Код:
float MyFloat;
...
GetPlayerPos(params[1],&MyFloat,&...);
Reply
#8

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
I don't know how you code but the way i avoid the float problem is:
pawn Код:
float MyFloat;
...
GetPlayerPos(params[1],&MyFloat,&...);
You should reference it or you will get astonishing result like I did.
Reply
#9

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
You should reference it or you will get astonishing result like I did.
Quote:
pawn Код:
if (std::strcmp(cmdtext, "/pos") == 0) {        float x, y, z;      GetPlayerPos(playerid, &x, &y, &z);     char message[128];      std::sprintf(message, "You are at (%f, %f, %f)", x, y, z);      SendClientMessage(playerid, 0xFFFFFFFF, message);       return 1;   }
:P that's WHY I use &... ;P
Reply
#10

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
:P that's WHY I use &... ;P
SA-MP GDK is messed up on R2 800p version. The playerid is messed up. Waiting for new version.
Reply
#11

Im not really sure why you chose this tittle for the thread, since none of this so far has really been related to the GDK. Its all been basic C++ problems, nothing GDK related. Im going to be adding the GDK to my plugin development guide soon (been saying this for a while, i know) so hopefully less people have issues with using the library.

Btw its not a reference you two are using, in that usage its the address-of operator.

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
SA-MP GDK is messed up on R2 800p version. The playerid is messed up. Waiting for new version.
Im assuming you mean callbacks are bugged when there are multiple plugins using the GDK? If so you should update any other plugins that use the GDK as most of them have a patched version available (disabled callback hooks basically). If your gonna release your plugin publicly its also a good idea to disable the callback hooks and go through PAWN until the issues are resolved. You can find more information on this in the math plugin thread.
Reply
#12

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Im not really sure why you chose this tittle for the thread, since none of this so far has really been related to the GDK. Its all been basic C++ problems, nothing GDK related. Im going to be adding the GDK to my plugin development guide soon (been saying this for a while, i know) so hopefully less people have issues with using the library.

Btw its not a reference you two are using, in that usage its the address-of operator.



Im assuming you mean callbacks are bugged when there are multiple plugins using the GDK? If so you should update any other plugins that use the GDK as most of them have a patched version available (disabled callback hooks basically). If your gonna release your plugin publicly its also a good idea to disable the callback hooks and go through PAWN until the issues are resolved. You can find more information on this in the math plugin thread.
Well we are creating a gamemode with SA-MP GDK and using two plugins which is streamer and mysql. We have made a simple command /goto <playerid> which will transport the client position to that specific playerid. But it transport to another playerid, not the specified playerid. So, I am assuming it's a SA-MP GDK problem.
Reply
#13

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Well we are creating a gamemode with SA-MP GDK and using two plugins which is streamer and mysql. We have made a simple command /goto <playerid> which will transport the client position to that specific playerid. But it transport to another playerid, not the specified playerid. So, I am assuming it's a SA-MP GDK problem.
Its hardly fair to just assume something like that, let alone spreading the information to others! Im willing to bet that its just something you're doing inside your code. My old GM's also use the GDK and have yet to suffer from anything like what you are claiming.
Reply
#14

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Its hardly fair to just assume something like that, let alone spreading the information to others! Im willing to bet that its just something you're doing inside your code. My old GM's also use the GDK and have yet to suffer from anything like what you are claiming.
Have you tested the latest SA-MP GDK with 0.3D R2 800p version? It's not my code problem I am 100% sure.
Reply
#15

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Have you tested the latest SA-MP GDK with 0.3D R2 800p version? It's not my code problem I am 100% sure.
Thats a pretty bold statement! I installed San Andreas, SA-MP 0.3D, and setup a small server running 0.3D / latest GDK version available just so i could test this (i know there are callback issues with multiple instances of GDK, so i wanted to be absolutely sure). The playerid parameter from the OnPlayerCommandText callback didnt give me a wrong value one single time, nor did the cmdtext string. If you're getting teleported to a player different from what you specify, it likely IS a code problem.

To confirm this im willing to take a look at your /goto command, even though you say you are 100% sure its not the problem (which once again is very bold).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)