Help With Quickstrings
#1

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

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;
}
Reply
#3

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

And thanks, will see if it work now.
Reply
#4

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

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

Код:
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;
}
Reply
#7

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)