Achievement point crash.
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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

Reply
#5

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.
Reply
#6

I wrote that Mine is full code
Reply
#7

Ah thank you everyone this should get it working
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)