SA-MP Forums Archive
Using const *[], len - 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: Using const *[], len (/showthread.php?tid=96202)



Using const *[], len - ilikepie2221 - 06.09.2009

Hi there. I'm trying to make a command in which info is automatically set to a specified string, like some commands. For example:

pawn Код:
RandomCommand(playerid,const bla[],len)
{
  new x[20];
  if(whatever == 1) x = "Yay, you cool";
  // More lines similiar to above
  x = bla
}
How would I go about including the "len"?


Re: Using const *[], len - dice7 - 06.09.2009

with strlen
https://sampwiki.blast.hk/wiki/Scripting...ons_Old#strlen


Re: Using const *[], len - ilikepie2221 - 07.09.2009

Well, now I have this:

pawn Код:
GetPlayerRankName(playerid,const rankz[],len)
{
  len = strlen(x)
  new x[20], rankz[len];
  if(whatever == 1) x = "Yay, you cool";
  // More ifs to define x
  rankz = x;
}
But I can't seem to get it. Can you give me an example, and I'll make it myself?


Re: Using const *[], len - snoob - 07.09.2009

Quote:
Originally Posted by ilikepie2221
Well, now I have this:

pawn Код:
GetPlayerRankName(playerid,const rankz[],len)
{
  len = strlen(x)
  new x[20], rankz[len];
  if(whatever == 1) x = "Yay, you cool";
  // More ifs to define x
  rankz = x;
}

But I can't seem to get it. Can you give me an example, and I'll make it myself?
hi

i would do something similar to that
pawn Код:
GetPlayerRankName(playerid)//
{
 new rankz[20];
 if(whatever == 1) format(rankz,sizeof(rankz),"Yay, you cool");
 else if(whatever == 2) format(rankz,sizeof(rankz),"wow your 1337 !!!");
 // More ifs to define x
 print(rankz); // you can print rankz in server screen for shit and giggle
 return rankz;// you could return rankz this way you can do: new string[xxx]; string = GetPlayerRankName(playerid)
}



Re: Using const *[], len - ilikepie2221 - 07.09.2009

Quote:
Originally Posted by snoob
Quote:
Originally Posted by ilikepie2221
Well, now I have this:

pawn Код:
GetPlayerRankName(playerid,const rankz[],len)
{
  len = strlen(x)
  new x[20], rankz[len];
  if(whatever == 1) x = "Yay, you cool";
  // More ifs to define x
  rankz = x;
}

But I can't seem to get it. Can you give me an example, and I'll make it myself?
hi

i would do something similar to that
pawn Код:
GetPlayerRankName(playerid)//
{
 new rankz[20];
 if(whatever == 1) format(rankz,sizeof(rankz),"Yay, you cool");
 else if(whatever == 2) format(rankz,sizeof(rankz),"wow your 1337 !!!");
 // More ifs to define x
 print(rankz); // you can print rankz in server screen for shit and giggle
 return rankz;// you could return rankz this way you can do: new string[xxx]; string = GetPlayerRankName(playerid)
}
I can't do that for what I have in my script. I need to use "const string[], len".


Re: Using const *[], len - ilikepie2221 - 07.09.2009

12 hr bump