Strings in Pawno
#1

Hey guys!

Im new at scripting and I dont really understand strings! I was hoping you guys could give me some professional advice! For example, how can i use /score cmd which tells people their score using strings. Plz help!!! I mean i understand the GetPlayerName one, but how can i use GetPlayerScore

Greetz, Tiger

Edit: Sorry for double post, laggy internet connection made me do it!
Reply
#2

Wrong section.
http://forum.sa-mp.com/index.php?board=10.0
By the way, you can GetPlayerScore as easy as you can GetPlayerName.

pawn Код:
new string[128]
format(string,128,"Your score is %i",GetPlayerScore(playerid)); // note: i'm not sure if 'i' is the right one, I haven't used that for numbers
SendClientMessage(playerid,color,string);
Note: This has not been tested.
Reply
#3

Quote:

// note: i'm not sure if 'i' is the right one, I haven't used that for numbers

I think its %d for numbers
Right now i get it, but what if say, im making a dm and i want to give the player a minigun if he gets more than 3 kills. How can i do this

Yh sorry, i realised it after i had posted, and u cant delete after u have posted
Reply
#4

It's the same if you use %d or %i, both formats are for integers (numbers as you say).

Quote:
Format Strings
Placeholder Meaning
%b Inserts a number at this position in binary radix
%c Inserts a single character.
%d Inserts an integer (whole) number
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'
Reply
#5

pawn Код:
zcmd(score, playerid, params[])
{
    new score, string[128];
    score = GetPlayerScore(playerid);
    format(string, sizeof(string), "Score = \"%d\"", score);
    SendClientMessage(playerid, white, string);
    return 1;
}
EDIT: My bad, forgot the new string[128];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)