ZCMD Problem
#1

Now it is like this:

Quote:

//------------------------------------------------------------------------------
/*public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}*/
//------------------------------------------------------------------------------
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) return SendClientMessage(playerid, -1, "SERVER: Unknown command.");
return 1;
}
//------------------------------------------------------------------------------

And it was like this:

Quote:

//------------------------------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}
//------------------------------------------------------------------------------
/*public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 0;
}*/
//------------------------------------------------------------------------------

How it is better? I have zcmd.inc.


I recived this error(crashdetect) + crash server.

Quote:

[09:15:18] [debug] Run time error 4: "Array index out of bounds"
[09:15:18] [debug] Accessing element at index 32 past array upper bound 31
[09:15:18] [debug] AMX backtrace:
[09:15:18] [debug] #0 00008840 in public OnPlayerCommandText (playerid=5, cmdtext[]=@001d7ad8 "////////////////////////////////////////") at D:\SCRIPTING [MY WORK]\RPG SERVER [0.3.7]\pawno\include\zcmd.inc:95

Reply
#2

Line 95 in zcmd.inc

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(isnull(cmdtext)) return 0;
if (zcmd_g_HasOPCS && !CallLocalFunction("OnPlayerCommandReceived", "is", playerid, cmdtext))
{
return 1;
}
new
pos,
funcname[MAX_FUNC_NAME];
while (cmdtext[++pos] > ' ')
{
funcname[pos-1] = tolower(cmdtext[pos]);
}
format(funcname, sizeof(funcname), "cmd_%s", funcname);
while (cmdtext[pos] == ' ') pos++;
if (!cmdtext[pos])
{
if (zcmd_g_HasOPCE)
{
return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, "\1"));
}
return CallLocalFunction(funcname, "is", playerid, "\1");
}
if (zcmd_g_HasOPCE)
{
return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos]));
}
return CallLocalFunction(funcname, "is", playerid, cmdtext[pos]);
}

Reply
#3

http://forum.sa-mp.com/showpost.php?...&postcount=482
Reply
#4

Quote:

while (cmdtext[++pos] > ' ')
{
if(pos > MAX_FUNC_NAME)
break;
else
funcname[pos-1] = tolower(cmdtext[pos]);
}

It only replaces that?

Quote:

while (cmdtext[++pos] > ' ')
{
funcname[pos-1] = tolower(cmdtext[pos]);
}

Reply
#5

Yes, only this line:
pawn Код:
funcname[pos-1] = tolower(cmdtext[pos]);
with:
pawn Код:
if(pos > MAX_FUNC_NAME) break;
else funcname[pos-1] = tolower(cmdtext[pos]);
Reply
#6

And this??

Now it is like this:

Quote:
//
Quote:

------------------------------------------------------------------------------
/*public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}*/
//------------------------------------------------------------------------------
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) return SendClientMessage(playerid, -1, "SERVER: Unknown command.");
return 1;
}
//------------------------------------------------------------------------------

And it was like this:

Quote:
Quote:

//------------------------------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}
//------------------------------------------------------------------------------
/*public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 0;
}*/
//------------------------------------------------------------------------------

How it is better? I have zcmd.inc.
Reply
#7

Returning 0 will give the "SERVER: Unknown command." message anyway. The first one is only used if you want to display a custom message like "Commmand does not exist. Check /cmds out!"
Reply
#8

Ok. How it is better functions?

Quote:

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 1;
}

OR

Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
return 1;
}

FOR ZCMD!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)