Some cmds -
Ironboy500 - 17.08.2009
Hello, I just made my new server and I would like to script /report cmd.
I write in pawno this for code:
if (strcmp(cmd, "/report id reason ") == 0)
{
if (strlen(cmdtext) >

{
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "Report from %s(%d): %s", playername, playerid, cmdtext[8]);
SendMessageToAdmins(string);
format(string, sizeof(string), "Report sent to currently online admins.");
SendMessage(playerid, string);
}
else {
format(string, sizeof(string), "Usage: /report id <text to send>");
SendMessage(playerid, string);
}
return 1;
What is wrong with him, I save it and start my server, I write /report id reason and "SEERVER: Unaknown command"
Please help?
Re: Some cmds -
dice7 - 17.08.2009
You need to use strtok or dcmd+sscanf to work
https://sampwiki.blast.hk/wiki/Strtok
https://sampwiki.blast.hk/wiki/Fast_Commands
Re: Some cmds -
Ironboy500 - 17.08.2009
ok thanks
Re: Some cmds -
MenaceX^ - 17.08.2009
pawn Код:
if (strcmp(cmd, "/report id reason ") == 0)
Oo?
Re: Some cmds -
XtremeChio - 17.08.2009
Quote:
Originally Posted by MenaceX^
pawn Код:
if (strcmp(cmd, "/report id reason ") == 0)
Oo?
|
Lol

But we all make mistakes heh.
Re: Some cmds -
urkiefly101 - 17.08.2009
I think the guy doesn't get it..
Re: Some cmds -
ilikepie2221 - 17.08.2009
Take out the "id reason", so
pawn Код:
if (strcmp(cmd, "/report") == 0)
Re: Some cmds -
coole210 - 18.08.2009
If you wanted to figure this out yourself, i'm sorry
pawn Код:
if(strcmp(cmdtext, "/report", true, 7)==0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "[ ! ] USAGE: /report [ID] [message]");
giveplayerid = strval(tmp);
if(!strlen(cmdtext[8])) return SendClientMessage(playerid, 0xFF0000AA, "Use /report [ID] [message]");
new str[128];
if((gettime()-LastReport[playerid]) < 30)
{
format(str, 128, "[ ! ] You have to wait %d seconds before you can send a new report!", (30-(gettime()-LastReport[playerid])));
SendClientMessage(playerid, 0xFF0000AA, str); return 1;
}
GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
format(str, 128, "[REPORT] Sender ID: %d Victim ID: %d Victim: %s Message: %s", playerid,giveplayerid,giveplayer, cmdtext[8]);
for(new i; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i) && IsPlayerAdmin(i)){
SendClientMessage(i, 0x00FFFFAA, str);
}}
SendClientMessage(playerid, 0x00FF00AA, "Report sent to online admins!");
LastReport[playerid] = gettime();
return 1;
}
Re: Some cmds -
XCultz - 18.08.2009
nicesaa
Re: Some cmds -
Ironboy500 - 18.08.2009
sorry, I add strtok code and after it this cmd code and it is not working:
Strtok code:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
and this /report code
if(strcmp(cmdtext, "/report", true, 7)==0)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "[ ! ] USAGE: /report [ID] [message]");
giveplayerid = strval(tmp);
if(!strlen(cmdtext[8])) return SendClientMessage(playerid, 0xFF0000AA, "Use /report [ID] [message]");
new str[128];
if((gettime()-LastReport[playerid]) < 30)
{
format(str, 128, "[ ! ] You have to wait %d seconds before you can send a new report!", (30-(gettime()-LastReport[playerid])));
SendClientMessage(playerid, 0xFF0000AA, str); return 1;
}
GetPlayerName(giveplayerid,giveplayer,sizeof(givep layer));
format(str, 128, "[REPORT] Sender ID: %d Victim ID: %d Victim: %s Message: %s", playerid,giveplayerid,giveplayer, cmdtext[8]);
for(new i; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i) && IsPlayerAdmin(i)){
SendClientMessage(i, 0x00FFFFAA, str);
}}
SendClientMessage(playerid, 0x00FF00AA, "Report sent to online admins!");
LastReport[playerid] = gettime();
return 1;

What do do? Can somebody explain me or give a web page?