Using const *[], len
#1

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"?
Reply
#2

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

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?
Reply
#4

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)
}
Reply
#5

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".
Reply
#6

12 hr bump
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)