SA-MP Forums Archive
String Arrays? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: String Arrays? (/showthread.php?tid=81776)



String Arrays? - lavamike - 13.06.2009

I am trying to figure out if I can store a string to an array. Basically when somebody joins the IRC Channel they are assigned an ID and their name is stored in that ID. This is what I have right now...

pawn Код:
// Top of Script
new MAX_USERS = 50;
new CurrentUsers = 0;
new Users[MAX_USERS]; // Line 45

// Inside Script
public ircOnUserJoin(conn, channel[], user[])
{
    new JoinMsg1[150];
    new JoinMsg2[50];
    format(JoinMsg1, sizeof(JoinMsg1), "Hey %s! Welcome to the Parallel Universe:Deathmach IRC Channel!", user);
    format(JoinMsg2, sizeof(JoinMsg2), "Your current IRC User ID is %i! Have Fun!", CurrentUsers);
    Users[CurrentUsers] = user; // Line 17120
    return 1;
}
But then I get:

Код:
C:\Documents and Settings\Mike C\Desktop\SAMP Server\ParUni\gamemodes\basics.pwn(45) : error 008: must be a constant expression; assumed zero
C:\Documents and Settings\Mike C\Desktop\SAMP Server\ParUni\gamemodes\basics.pwn(45) : error 009: invalid array size (negative, zero or out of bounds)
C:\Documents and Settings\Mike C\Desktop\SAMP Server\ParUni\gamemodes\basics.pwn(17120) : error 006: must be assigned to an array

So is there anyone who knows how I can achieve something like this? Any help is appreciated!

Thanks,
-Mike


Re: String Arrays? - miokie - 13.06.2009

pawn Код:
strmid(Users[CurrentUsers],user,0,128,128);
That's how I would do it.