SA-MP Forums Archive
Help making - Quick Strings - 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: Help making - Quick Strings (/showthread.php?tid=556982)



Help making - Quick Strings - Airman123 - 12.01.2015

Hello, I've been making quick strings, but none of them works, as i want them to work.

Like i made,
under OnplayerText
Код:
if(!strcmp(text, "$loc", true))
{
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
	    new zone[MAX_ZONE_NAME];
	    GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
		format(string, sizeof(string), "{FFFFFF}%s: {FFFFFF}%s",pName,zone);
		SendClientMessageToAll(COLOR_WHITE, string);
		return 0;
}
This one works only when i type "$loc" in the chat, not when i type "in in $loc" - "im in bayside"

How to make it like that? please halp


Re: Help making - Quick Strings - 1fret - 12.01.2015

If you want it to work when you type /$loc you got to put it a onplayercommandtext.


Re: Help making - Quick Strings - Airman123 - 12.01.2015

Im not asking to make a command lol, i just want Under OnPlayerText, when players types "$loc" it should show the current location.
Like player say: im in $loc
Output: Im in Bayside bla bla


Re: Help making - Quick Strings - rickisme - 12.01.2015

use strfind ( https://sampwiki.blast.hk/wiki/Strfind )


Re: Help making - Quick Strings - Airman123 - 12.01.2015

I tried it, didn't worked. Can u make the Code for me using "strfind".


Re: Help making - Quick Strings - 1fret - 12.01.2015

Try this
pawn Код:
if(text[0] == '$loc')
  {
     new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
    new zone[MAX_ZONE_NAME];
    GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
format(string, sizeof(string), "{FFFFFF}%s: {FFFFFF}%s",pName,zone);
SendClientMessageToAll(COLOR_WHITE, string);
}
Sorry for loose indentation warning I'm on my phone


Re: Help making - Quick Strings - Airman123 - 12.01.2015

okay i try. Return 0; needed or Not.
Edit: btw where is "strfind" in it


Re: Help making - Quick Strings - zT KiNgKoNg - 12.01.2015

Go learn, look at the Wiki (it'll help you out allot), besides that asking here isn't always the solution.


Re: Help making - Quick Strings - Airman123 - 12.01.2015

Wiki shows the functions, i tried everyone.. But still bugs. Thats why im asking here.


Re: Help making - Quick Strings - rickisme - 12.01.2015

Example code :
pawn Код:
main(){

    new
        zone[32] = { "Bayside" },
        text[64] = { "Hello, im at $loc, come here please " };

    if(strfind(text, "$loc", true) != -1)
    {
        new
            pos = strfind(text, "$loc", true);
   
        strdel(text, pos, pos + strlen("$loc"));
        strins(text, zone, pos);
        printf("Rick_Tran: %s", text);
    }
   
}
result :
pawn Код:
[20:23:51] Rick_Tran: Hello, im at Bayside, come here please