SA-MP Forums Archive
And stuck again with this - 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: And stuck again with this (/showthread.php?tid=292378)



And stuck again with this - iNorton - 23.10.2011

Similar to my old post on /me now on /do ... I do have to say local chats are my worse sections when doing script, normal cmds is normal for me...

So here is the script

pawn Код:
COMMAND:do(playerid, params[])
{
    new text[128], string[128];
    if(sscanf(params, "s[127]", text)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /do [Environment]");
    format(string, sizeof(string), "** %s (( %s ))", text, Character[playerid][cName], params);
    PlayerLocalMessage(15.0, playerid, string, COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE);
    return 1;
}
And what happens is that when ever you do /do test it does [SYNTAX]: /do [Environment] no text beside that appears.

Did I missed anything in the /do script? Or made wrong?


Re: And stuck again with this - SchurmanCQC - 23.10.2011

/do is the exact same as /me, just a different syntax message and different message that comes out when you type it..

edit: try if(!sscanf(params, "s[127]", text))


Re: And stuck again with this - JaTochNietDan - 23.10.2011

I don't really understand why you need to use sscanf in this code, there is no need to use sscanf here. It is for unformatting code, not checking if a string is not empty. Here is a fixed example of this code:

pawn Код:
COMMAND:do(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /do [Environment]");
    new string[128];
    format(string, sizeof(string), "** %s (( %s ))", Character[playerid][cName], params);
    PlayerLocalMessage(15.0, playerid, string, COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE);
    return 1;
}



Re: And stuck again with this - iNorton - 23.10.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
I don't really understand why you need to use sscanf in this code, there is no need to use sscanf here. It is for unformatting code, not checking if a string is not empty. Here is a fixed example of this code:

pawn Код:
COMMAND:do(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /do [Environment]");
    new string[128];
    format(string, sizeof(string), "** %s (( %s ))", Character[playerid][cName], params);
    PlayerLocalMessage(15.0, playerid, string, COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE,COLOR_MEDIUMPURPLE);
    return 1;
}
People say you gotta use sscanf with zcmd :\ oh well thank you...


Re: And stuck again with this - JaTochNietDan - 23.10.2011

Quote:
Originally Posted by iNorton
Посмотреть сообщение
People say you gotta use sscanf with zcmd :\ oh well thank you...
Well they are wrong, you only use sscanf when it is needed, if you're using multiple parameters, then you should use sscanf to split and "unformat" the string, as that is the nature of what sscanf is made for.


Re: And stuck again with this - iNorton - 23.10.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well they are wrong, you only use sscanf when it is needed, if you're using multiple parameters, then you should use sscanf to split and "unformat" the string, as that is the nature of what sscanf is made for.
Now I get it, done /b aka local ooc without a problem now owe u a lot man!