SA-MP Forums Archive
Achievement point crash. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Achievement point crash. (/showthread.php?tid=141583)



Achievement point crash. - VizAida - 14.04.2010

i'm trying to get this script to fetch the amount of point but every time i try to fetch the amount it crash the server.

heres the script

Код:
new game_pt
new string[4];
format(string,sizeof(string), "You have earned %s GP.", game_pt);
SendClientMessage(playerid, COLOR_GREEN, string);
thanks in advance.


Re: Achievement point crash. - RichyB - 14.04.2010

try and do
new pt;
new string[4];
format(string,sizeof(string), "You have earned %s GP.", pt);
SendClientMessage(playerid, COLOR_GREEN, string);

It could have been because of the UnderScore "_"
That could be one problem, but I just thought of the most possible one.
When are the players points being given?
What function gives the player points?
Is it the players score?

If it is, delete new game_pt; or new pt;
And do
new game_pt = PlayerPointFunction;
And replace that with your fuction that gives the player points
I am not a Pro, I am still learning.
I am tired so I don't know if this will help or if it makes sense xD.
But if it helps at all, well GoodLuck with your script.

_*Unrelated*_
Whats the Maximum Points you can get?
9999?
If it can get higher, you could change the 4 in new string[4]; to new string[10];
Thats nothing to do with the crash, but just so the string fully displays.



Re: Achievement point crash. - Correlli - 14.04.2010

Add ; at the end of the game_pt variable, and %s is for formatting strings, correct would be %i or %d, but game_pt will always show 0 at this code.
Also, 4 cells in string array isn't enough to format that message.


Re: Achievement point crash. - Thrarod - 14.04.2010

pawn Код:
new game_pt;
new string[32];
format(string,sizeof(string), "You have earned %d GP.", game_pt);
SendClientMessage(playerid, COLOR_GREEN, string);
Should work!

Changed-

-new string[4]; to new string[32];
-new game_pt to new game_pt;
-%s to %d




Re: Achievement point crash. - RichyB - 14.04.2010

Quote:

Also, 4 cells in string array isn't enough to format that message.

LOL just noticed that.
VizAida in the cells place 32.
That should be enough for string to show.



Re: Achievement point crash. - Thrarod - 14.04.2010

I wrote that Mine is full code


Re: Achievement point crash. - VizAida - 15.04.2010

Ah thank you everyone this should get it working


Re: Achievement point crash. - cessil - 15.04.2010

if it doesn't then use
new game_pt = 0;

if anything would crash it in that code it'd probably be the fact that you're trying to put variable worth nothing into a string