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)
+--- Thread: String Arrays (
/showthread.php?tid=282163)
String Arrays -
Luis- - 09.09.2011
Hello, I am planning to release something that came to my mind but I need to know how to make string arrays, example:
pawn Код:
new Languages[][] =
{
"English",
"Scottish"
}
Re: String Arrays -
FireCat - 09.09.2011
pawn Код:
new Languages[][] =
{
"English",
"Scottish"
}
public OnPlayerConnect(playerid)
{
print(Languages[0]);
return 1;
}
Re: String Arrays -
Luis- - 09.09.2011
Alrighty, how would this code actually work?
pawn Код:
new name[MAX_PLAYER_NAME];
if(GetPlayerName(playerid, name, sizeof(name)) == CelebNames[0])
{
return 1;
}
Re: String Arrays -
FireCat - 09.09.2011
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name))
if(strcmp(name,CelebNames[0]) == 0)
{
return 1;
}
Re: String Arrays -
Daniel-92 - 09.09.2011
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i < sizeof(CelebNames); i++) {
if(strcmp(name,CelebNames[i],true) == 0) {
return 1;
}
}
Re: String Arrays -
Luis- - 09.09.2011
Its either me doing something wrong or those codes aren't working correctly.
Re: String Arrays -
FireCat - 09.09.2011
Quote:
Originally Posted by -Luis
Its either me doing something wrong or those codes aren't working correctly.
|
Show CelebNames
Re: String Arrays -
Luis- - 09.09.2011
pawn Код:
new CelebNames[1][20] =
{
"David_Beckham"
};
Don't worry, I will add more once its working.
Re: String Arrays -
Daniel-92 - 10.09.2011
I will give you an example how to use the function
pawn Код:
new CelebNames[][] = {
"David_Beckham"
};
public OnPlayerConnect(playerid) {
if(IsCelebName(playerid)) {
SendClientMessage(playerid,0xFFFF00AA,"** You have a celebrity name");
//Kick(playerid);
}
}
IsCelebName(playerid) {
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new i = 0; i < sizeof(CelebNames); i++) {
if(strcmp(name,CelebNames[i],true) == 0) {
return 1;
}
}
return 0;
}