What am I doing wrong ?
#1

hey scripters
i started witch sscanf/dcmd
what is wrong here
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    dcmd(ban, 3, cmdtext);
	dcmd_ban(playerid, params[])
	{
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	if(!IsPlayerAdmin(playerid)) return 0;
	new targetid, reason[64], string[128];
	if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /ban [playerid/partofname] [reason]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player not connected or is yourself!");
	format(string, sizeof(string), "%s has been banned (Reason: %s)",pName, reason);
	SendClientMessageToAll(COLOR_RED, string); // Sending the string to all
	Ban(targetid);
	}
}
PHP код:
(1326) : error 017undefined symbol "dcmd_ban"
(1327) : error 017undefined symbol "dcmd_ban"
(1333) : error 017undefined symbol "params" 
Reply
#2

pawn Код:
if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /ban [playerid/partofname] [reason]");
You must define the string size in the sscanf line aswell. Like this;
z[64]

pawn Код:
if(sscanf(params, "uz[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /ban [playerid/partofname] [reason]");
And i believe with DCMD you must define it under OnPlayerCommandText aswell.
Reply
#3

Quote:
Originally Posted by bijoyekuza
Посмотреть сообщение
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    dcmd(ban, 3, cmdtext);
	dcmd_ban(playerid, params[])
	{
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	if(!IsPlayerAdmin(playerid)) return 0;
	new targetid, reason[64], string[128];
	if(sscanf(params, "uz", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /ban [playerid/partofname] [reason]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player not connected or is yourself!");
	format(string, sizeof(string), "%s has been banned (Reason: %s)",pName, reason);
	SendClientMessageToAll(COLOR_RED, string); // Sending the string to all
	Ban(targetid);
	}
}
dcmd_ban should not be it OnPlayerCommandText, but below it
Reply
#4

And by the way if your starting dcmd don't do it... Start zcmd + sscanf much better and easier..

Here a toturial if you want to learn it... Just the something, only change the format and dont need dcmd(ban, 3, cmdtext);

http://forum.sa-mp.com/showthread.ph...45#post1120045
Reply
#5

Right code:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(ban, 3, cmdtext);
    return 1;
}
   
dcmd_ban(playerid, params[])
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!IsPlayerAdmin(playerid)) return 0;
    new targetid, reason[64], string[128];
    if(sscanf(params, "uz[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /ban [playerid/partofname] [reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player not connected or is yourself!");
    format(string, sizeof(string), "%s has been banned (Reason: %s)",pName, reason);
    SendClientMessageToAll(COLOR_RED, string); // Sending the string to all
    Ban(targetid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)