Array, Strings problem
#1

I still don't get how does the arrays works in pawno... As far as i know when we use a string to format some message or something we use %s for string %f for float %i for integer and so on.. But why when i try to print an array it prints me some random unknown symbol instead of the string i assign to the array. It prints me the first and the last letter of the string and also some E which looks like Euro symbol.. But i have maded another print and it prints me the name perfectly. There is a bit of my code:
format(playercar[ucarsn][car_owner],256,"Paranoja");
format(playerhouse[uhousesn][house_owner],256,"Paranoja");

First script works perfectly (it says: |SERVER|: This car belongs to the citizen called NAME.)
Код:
format(ownermessage, sizeof(ownermessage), "|SERVERIS|: Maрina priklauso pilieиiui vardu %s.", playercar[ucarsn][car_owner]);
SendClientMessage(playerid,COLOR_SERVER,ownermessage);
Second script prints only the first and the last letters (|SERVER|: This house belongs to the citizen called N Ђ E)
Код:
format(ownermessage,sizeof(ownermessage),"|SERVERIS|: Namas priklauso pilieиiui vardu %s.",playerhouse[uhousesn][house_owner]);
SendClientMessage(playerid,COLOR_SERVER,ownermessage);
How should I assign the string to the array so that i can print it and to check if it matches the string i specify for example:
Код:
if (playerhouse[uhousesn][house_owner] == "niekas") {
It returns me an error, but it would work perfectly on PHP, can any one fully explain how does the arrays works in pawno or give some link or something, thank you.
Reply
#2

To see if one string equals another, you should use strcmp.

https://sampwiki.blast.hk/wiki/Strcmp

if(!strcmp(playerhouse[uhousesn][house_owner], "niekas")) {

By default it is case senstive, to make it "insensitive", use:

if(!strcmp(playerhouse[uhousesn][house_owner], "niekas", true)) {

_________________________________________________

Array information:

https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
https://sampwiki.blast.hk/wiki/Advanced_Structures
Reply
#3

I know about that, seems like it works, but why i can't just print out the string? Why it gives me some random characters instead of the word it has to return.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)