SA-MP Forums Archive
Why is this not working? - 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)
+--- Thread: Why is this not working? (/showthread.php?tid=627787)



Why is this not working? - AndreiWow - 01.02.2017

Sorry for the title but wasn't sure about a good one..

PHP код:
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(2753) : error 006must be assigned to an array
C:\Users\andrei\Desktop\Scripting SA-MP\Basic RP Script Scratch FIX\gamemodes\U1.pwn(2754) : error 006must be assigned to an array
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors

PHP код:
new test[64][7]; 
PHP код:
 if(PlayerInfo[playerid][pItem1] == 1) { test[0] = "Test String"; }
        if(
PlayerInfo[playerid][pItem2] == 0) { test[1] = "EMPTY"; }
        if(
PlayerInfo[playerid][pItem3] == 0) { test[2] = "EMPTY"; }
        if(
PlayerInfo[playerid][pItem4] == 0) { test[3] = "EMPTY"; }
        if(
PlayerInfo[playerid][pItem5] == 0) { test[4] = "EMPTY"; }
        if(
PlayerInfo[playerid][pItem6] == 0) { test[5] = "EMPTY"; }
        if(
PlayerInfo[playerid][pItem7] == 0) { test[6] = "EMPTY"; } 
I also tried new test[7][64] which made the error go away but I wasn't getting the full text, I was receiving only this "Test Strin"


Re: Why is this not working? - Eoussama - 01.02.2017

I'd rather do it this way
PHP код:
    new test[1][6]; 
    if(
PlayerInfo[playerid][pKicks] == 1)
                
format(test[0], sizeof(test[0]), "EMPTY"); 



Re: Why is this not working? - AndreiWow - 01.02.2017

Quote:
Originally Posted by TATIK
Посмотреть сообщение
PHP код:
new test[7][64]; 
I did that but it didn't worked, nevermind I solved anyway, I had the format string too small... thanks anyway


Re: Why is this not working? - Lordzy - 01.02.2017

You don't have to use 2-dimensional arrays for a single string. It could simply be test[64]. Also, I suggest you to use strcpy to copy strings than using format.


Re: Why is this not working? - AndreiWow - 01.02.2017

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
You don't have to use 2-dimensional arrays for a single string. It could simply be test[64]. Also, I suggest you to use strcpy to copy strings than using format.
Can you show me an example of strcpy?