SA-MP Forums Archive
Help With Quickstrings - 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: Help With Quickstrings (/showthread.php?tid=124640)



Help With Quickstrings - [03]Garsino - 31.01.2010

Hey guys, I need help with making quickstrings.
If you dont know what quickstrings is I'm gonna tell you:

Like f.ex. $veh - Will show your current vehicle or on foot if you're not in a vehicle.

Like - [03]Garsino: I'm In a $veh At San Andreas.
Will show up as - [03]Garsino: I'm In a Cheetah At San Andreas.

I hope anyone know how to do this, thanks

-[03]Garsino


Re: Help With Quickstrings - [HiC]TheKiller - 31.01.2010

Firstly find the pos using https://sampwiki.blast.hk/wiki/Strfind . Then delete the veh part using https://sampwiki.blast.hk/wiki/Strdel . Then we will insert the right $veh thing using https://sampwiki.blast.hk/wiki/Strins. Also, Nice copying crazybobs .

EDIT (Example):

pawn Код:
public OnPlayerText(playerid, text[])
{
  new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", /*VehicleNamesList*/);
    strins(text,str, Check);
  }
  return 1;
}



Re: Help With Quickstrings - [03]Garsino - 31.01.2010

Nah, not copying CB's. Just need it for my server

And thanks, will see if it work now.


Re: Help With Quickstrings - [03]Garsino - 31.01.2010

EDIT: [...] FunServer.pwn(11166) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")

pawn Код:
public OnPlayerText(playerid, text[])
{
  new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check = Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", PlayerVehicle);
    strins(text,Str,Check = Check - 3); // 11166
  }
    return 1;
}



Re: Help With Quickstrings - [HiC]TheKiller - 31.01.2010

Quote:
Originally Posted by [03
Garsino ]
EDIT: [...] FunServer.pwn(11166) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")

pawn Код:
public OnPlayerText(playerid, text[])
{
  new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check = Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", PlayerVehicle);
    strins(text,Str,Check = Check - 3); // 11166
  }
    return 1;
}
My bad, it's late, fixed it.


Re: Help With Quickstrings - [03]Garsino - 31.01.2010

Код:
FunServer.pwn(11224) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
pawn Код:
public OnPlayerText(playerid, text[])
{
 new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check = Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", PlayerVehicle);
    strins(text,Str, Check); // 11224
  }
    return 1;
}



Re: Help With Quickstrings - [HiC]TheKiller - 31.01.2010

Quote:
Originally Posted by [03
Garsino ]
Код:
FunServer.pwn(11224) : warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
pawn Код:
public OnPlayerText(playerid, text[])
{
 new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check = Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", PlayerVehicle);
    strins(text,Str, Check); // 11224
  }
    return 1;
}
I just realized what the problem was :P, sizeof doesn't work on text[] so use strlen.

pawn Код:
public OnPlayerText(playerid, text[])
{
  new Check = strfind(text, "$veh");
  if(Check != -1)
  {
    strdel(text, Check, Check + 3);
    new Str[56];
    format(Str, sizeof(Str), "%s", /*VehicleNamesList*/);
    strins(text,Str, Check, strlen(text));
  }
  return 1;
}