/report problem
#1

hey guyz
i have a script for a report command.
it works a little because when i do "/report" it sends the admin a message "report from MeNMyselv".
and i want that when you do "/report" that it sends a client message like "Usage: /report [ID/username] [Reason]"

and when i do for a test "/report 0 spawnkill"
it says Unknown Command.

Here's the code:
Код:
    if (strcmp("/report", cmdtext, true, 10) == 0)
 	{
	    new str[200];
	    new idx;
	    GetPlayerName(playerid, str, 24);
	    new length = strlen(cmdtext);
	    while ((idx < length) && (cmdtext[idx] <= ' '))
	    {
	        idx++;
	    }
	    new offset = idx;
	    new result[96];
	    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
	    {
	        result[idx - offset] = cmdtext[idx];
	        idx++;
	    }
	    result[idx - offset] = EOS;
	    if(!strlen(result)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /report [ID] [Reason]");
	    format(str, sizeof str, "Report from [%d] %s: %s", playerid, str, result);
	    for(new i = 0; i < MAX_PLAYERS; i ++) { if(IsPlayerAdmin(i)) SendClientMessage(i, 0xFFFF00FF, str); }
	    SendClientMessage(playerid, 0xFFFF00FF, "Your report message was sent to online administrators, thank you.");
	    SendClientMessage(playerid, 0xFFFF00FF, "We will find a solution soon. We will let you know what we did.");
	    return 1;
	}
plz help me hope you can fix it

srry if bad English but im Dutch
THNX for interest and maybe for helping
Reply
#2

PHP код:
if(strcmp(cmd"/report"true) == 0)
{
    new 
str[256], idxn[24], n2[24];
    
str strtok(cmdtextidx);
    new 
length strlen(cmdtext);
    while ((
idx length) && (cmdtext[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[96];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = cmdtext[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    if(!
strlen(result) || !strlen(str)) return SendClientMessage(playerid0xFFFFFFFF"USAGE: /report [id] [reason]");
    if(!
IsPlayerConnected(strval(str) || strval(str) == INVALID_PLAYER_ID) return SendClientMessage(plaeyrid0xFF0000FF"INVALID ID.");
    
GetPlayerName(playeridn24);
    
GetPlayerName(strval(str), n224);
    
format(strsizeof str"%s [%d] was reported by %s [%d] | Reason: %s"n2strval(str), strplayeridresult);
    for(new 
0MAX_PLAYERS++) { if(IsPlayerAdmin(i)) SendClientMessage(i0xFFFF00FFstr); }
    
SendClientMessage(playerid0xFFFF00FF"Your report message was sent to online administrators, thank you.");
    return 
1;

Note: IT'S YOUR THIRD THREAD ABOUT THE SAME THING ! ¬¬'

https://sampforum.blast.hk/showthread.php?tid=268371
https://sampforum.blast.hk/showthread.php?tid=268386
Reply
#3

PLZ HELP!!!!
Anyone help.
Reply
#4

PLZ HELP!!!!
Anyone help.

No one??
Reply
#5

@shadoww5
Srry didn't see your post im on tablet and i know that but its because no one responds
Reply
#6

@shadoww5
now i get these errors:

D:\Documents and Settings\ben\Mijn documenten\SAMP Server\gamemodes\LSF4A.pwn(324) : error 017: undefined symbol "strtok"
D:\Documents and Settings\ben\Mijn documenten\SAMP Server\gamemodes\LSF4A.pwn(324) : error 033: array must be indexed (variable "str")
D:\Documents and Settings\ben\Mijn documenten\SAMP Server\gamemodes\LSF4A.pwn(339) : error 001: expected token: ")", but found "return"

srry if im annoying but im noob in scripting don't know anything about it anymore
Reply
#7

Quote:

b) Do not bump
Some people apparently think they are important enough to bump their own topic after 10 minutes.
You can bump topics when the last reply is at least 48 hours old, and it needs to have useful information about your problem.

You'll just get yourself banned from sa-mp.com.


I would suggest using zcmd, because strcmp is outdated, very uncomfortable and etc. But it's your choice what command processor you want to use.
Reply
#8

@unte99
okay it's good

but how do i use zcmd then??
Reply
#9

Download the include from here http://forum.sa-mp.com/showthread.ph...highlight=zcmd
Put the include in the Yourserver/pawno/includes folder. Then in your gamemode at the top where

pawn Код:
#include <sa-mp>
is, add

pawn Код:
#include <zcmd>
And your'e good to go.

Write your commands not in callbacks(callback, ex.: OnGameModeInit). Not in callbacks. I would suggest after the OnPlayerCommandText callbacb, like this:

And also, it would be good if you would have sscanf2 or sscanf include. Sscanf2 link: http://forum.sa-mp.com/showthread.ph...hlight=sscanf2

pawn Код:
OnPlayerCommandText(..........)
{
    return 1;
}

////// MY COMMANDS

CMD:report(playerid, params[])
{
    new targetid, reason,message[50];
    if(!sscanf(params, "is", targetid,reason))
    format(message, sizeof message, "Report from [%i] %i: %s", playerid, targetid, reason);
    SendClientMessage(playerid, 0xFFFF00FF, "Your report message was sent to online administrators, thank you.");
    SendClientMessage(playerid, 0xFFFF00FF, "We will find a solution soon. We will let you know what we did.");
    return 1;
}

CMD:.....

CMD:.....

EDIT: Just added the message, that will be sent to the admins or someone... Just PM me if you don't understand something or if you want me to do that the report message would be sent to the admins.
Reply
#10

Command fixed:

PHP код:
if(strcmp(cmd"/report"true) == 0)
{
    new 
str[256], idxn[24], n2[24];
    
str strtok(cmdtextidx);
    new 
length strlen(cmdtext);
    while ((
idx length) && (cmdtext[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[96];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = cmdtext[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    if(!
strlen(result) || !strlen(str)) return SendClientMessage(playerid0xFFFFFFFF"USAGE: /report [id] [reason]");
    if(!
IsPlayerConnected(strval(str)) || strval(str) == INVALID_PLAYER_ID) return SendClientMessage(plaeyrid0xFF0000FF"INVALID ID.");
    
GetPlayerName(playeridn24);
    
GetPlayerName(strval(str), n224);
    
format(strsizeof str"%s [%d] was reported by %s [%d] | Reason: %s"n2strval(str), strplayeridresult);
    for(new 
0MAX_PLAYERS++) { if(IsPlayerAdmin(i)) SendClientMessage(i0xFFFF00FFstr); }
    
SendClientMessage(playerid0xFFFF00FF"Your report message was sent to online administrators, thank you.");
    return 
1;

And put this at the bottom of you GM:

PHP код:
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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)