Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
Hello guys, as the title says. When i use /o Hi, it says in chat "ЈЈЈя". No mather what i say, it keeps saying ''ЈЈЈя''. Here are the codes, i would really appriciate it when someone could help me.
Код:
stock GetPlayersName(playerid)
{
new playersName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playersName, MAX_PLAYER_NAME);
for(new i = 0; i < strlen(playersName); i++)
{
if(playersName[i] == '_') playersName[i] = ' ';
}
return playersName;
}
Код:
COMMAND:o(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid,0xA3A3A3FF,"USAGE: /o [TEXT]");
new string[126];
format(string, sizeof(string), "(( %s: %s ))", GetPlayerName(playerid), params);
SendClientMessageToAll(0xA3A3A3FF, string);
return 1;
}
Re: Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
i get these warnings too, if that helps you guys solving the problem.
Код:
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.2.pwn(1976) : warning 225: unreachable code
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.2.pwn(2176) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Tessa Krijnen\Mijn documenten\Fabians Fun Server (0.3e)\gamemodes\v4.2.pwn(2176) : warning 202: number of arguments does not match definition
Re: Need help with my /o command, Again. -
Skaizo - 10.08.2012
pawn Код:
CMD:o(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[56];
GetPlayerName(playerid, sendername, sizeof(sendername));
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFF,"Syntax error.Correct usage: /o [text]");
format(string, sizeof(string), "(( %s: %s ))", sendername, params);
SendClientMessageToAll(0xA3A3A3FF, string);
return 1;
}
without stock
Re: Need help with my /o command, Again. -
Jstylezzz - 10.08.2012
try to use sscanf, then make instead of if(IsNull(params))
this:
pawn Код:
new text[128];
if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,COLOR_RED,"Usage: /o [text]");
//then in format, do :
format(string, sizeof(string), "(( %s: %s ))", GetPlayerName(playerid), text);
good luck||veel succes
if you need any help, just tell
Re: Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
When i type ''/o Hi'' with that, the chat still says ''ЈЈЈя''.
Re: Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
how do i use Scanf?
Re: Need help with my /o command, Again. -
Jstylezzz - 10.08.2012
pawn Код:
CMD:o(playerid, params[])
{
new string[256];
if(sscanf(params, "s[128]",string)) return SendClientMessage(playerid, COLOR_RED,"Usage: /o <text>");
format(string, sizeof(string), "((OOC)): %s : %s ", GetPlayerName(playerid), params);
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
return 1;
}
here, you can have my /o code, i use it in my gamemode, so it should work for you too..
else, you are making some mistake somewhere
don't ask me why it is like this, i don't remember why i did it like this, it's a long time ago..
now that i look, it looks kinda the same as yours.
just try it, and tell us what happens
EDIT: depends, sscanf is usable for alot of things, if you use my code, it will be used to make correct sentences or something
Re: Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
Ok, Jari, i used your /o. Now we got another problem. When i use /o Hello, it keeps saying ''Usage: /o [text]". No mather what i say.
Re: Need help with my /o command, Again. -
CrazyManiac - 10.08.2012
So what i have now is this.
Код:
stock GetPlayersName(playerid)
{
new playersName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playersName, MAX_PLAYER_NAME);
for(new i = 0; i < strlen(playersName); i++)
{
if(playersName[i] == '_') playersName[i] = ' ';
}
return playersName;
}
And Jari's /o command:
Код:
COMMAND:o(playerid, params[])
{
new string[256];
if(sscanf(params, "s[128]",string)) return SendClientMessage(playerid,0x8A8A8AFF,"Usage: /o <text>");
format(string, sizeof(string), "((OOC)): %s : %s ", GetPlayerName(playerid), params);
SendClientMessageToAll(0x8A8A8AFF,string);
return 1;
}
But i still have the problem that it keeps saying how to use it.
Re: Need help with my /o command, Again. -
Scenario - 10.08.2012
This is your stock function: GetPlayersName(playerid)
This is what you're using in the command: GetPlayerName(playerid) -- you're missing an "s" for "players"
..