Help making - Quick Strings
#1

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

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

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

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

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

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

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)