String must be assigned to array
#1

Hi, im working on a ranking script and i want people to get a message when they rank up. However I don't know how to propperly use strings.

Код:
new newrank[MAX_PLAYERS];
new oldrank[MAX_PLAYERS];

        if (score[playerid] >= 300){
	    newrank[playerid] = "***Marshall***";
	}

        if(oldrank[playerid] != newrank[playerid]){
    	        format(stringb,sizeof(stringb),"~w~Rankup: ~g~%s",newrank[playerid]);
		GameTextForPlayer(playerid,stringb,2000,5);
	}
    oldrank[playerid] = newrank[playerid];
I left a lot of code out since it is not important for this question. but i get an error wich says that the array is not indexed. as you can see i indexed it to the playerid. please help
Reply
#2

pawn Код:
new newrank[MAX_PLAYERS][15];//15 as the len to store the string "newrank".
new oldrank[MAX_PLAYERS][15];//15 as the len to store the string "oldrank".

        if (score[playerid] >= 300){
        newrank[playerid] = "***Marshall***";
    }

        if(oldrank[playerid] != newrank[playerid]){
                format(stringb,sizeof(stringb),"~w~Rankup: ~g~%s",newrank[playerid]);
        GameTextForPlayer(playerid,stringb,2000,5);
    }
    oldrank[playerid] = newrank[playerid];
Reply
#3

Quote:
Originally Posted by Ken97
Посмотреть сообщение
pawn Код:
new newrank[MAX_PLAYERS][15];//15 as the len to store the string "newrank".
new oldrank[MAX_PLAYERS][15];//15 as the len to store the string "oldrank".

        if (score[playerid] >= 300){
        newrank[playerid] = "***Marshall***";
    }

        if(oldrank[playerid] != newrank[playerid]){
                format(stringb,sizeof(stringb),"~w~Rankup: ~g~%s",newrank[playerid]);
        GameTextForPlayer(playerid,stringb,2000,5);
    }
    oldrank[playerid] = newrank[playerid];
Ok, that cleared some errors. however i still get an error wich says that these need to be indexed:
Код:
        if(oldrank[playerid]//this != newrank[playerid]//this){
    	        format(stringb,sizeof(stringb),"~w~Rankup: ~g~%s",newrank[playerid]);
		GameTextForPlayer(playerid,stringb,2000,5);
	}
Reply
#4

Quote:
Originally Posted by klotebandit
Посмотреть сообщение
Ok, that cleared some errors. however i still get an error wich says that these need to be indexed:
Код:
        if(oldrank[playerid]//this != newrank[playerid]//this){
    	        format(stringb,sizeof(stringb),"~w~Rankup: ~g~%s",newrank[playerid]);
		GameTextForPlayer(playerid,stringb,2000,5);
	}
You can try Strcmp, since you're comparing two strings.
Reply
#5

Yes you have to use strcmp, you can't compare strings like that == etc...
Reply
#6

Quote:
Originally Posted by Ken97
Посмотреть сообщение
You can try Strcmp, since you're comparing two strings.
That did the trick, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)