All pastes #192031 Raw Edit

Untitled

public c v1 · immutable
·published 2006-10-05 16:25 UTC
rendered paste body
public OnPlayerCommandText(playerid, cmdtext[]){    enum VarsEnum	{	    cmd[256],	    tmp[256],	    tmp2[256],	    pname[MAX_PLAYER_NAME],	    idx	}	new Vars[VarsEnum];	Vars[pname] = PlayerName(playerid);		set(Vars[cmd],strtok(cmdtext, Vars[idx]));		SendMsg(playerid,"You used some command.");		if (OnPlayerCommandTextProp(playerid, cmdtext)) { return 1; }	return 0;}// At some other file -->public OnPlayerCommandTextProp(playerid, cmdtext[]){	enum PVarsEnum	{	    Pcmd[256],	    Pstring[256],	    Ppname[MAX_PLAYER_NAME],	    Penc_pname[256],	    Ppropowner[256],	    Ppropname[256],	    Ptmp[256],	    Ptmp2[256],	    Plist,	    Pidx	}		new PVars[PVarsEnum];	SendMsg(playerid,"Test 1");	set(PVars[Ppname],PlayerName(playerid));	SendMsg(playerid,"Test 2");	set(PVars[Penc_pname],udb_encode(PVars[Ppname]));	SendMsg(playerid,"Test 3");	set(PVars[Pcmd],strtok(cmdtext, PVars[Pidx]));		if (strcmp(PVars[Pcmd], "/moo", true) == 0)	{		SendMsg(playerid,"UhUh");		return 1;	}	return 0;}Functions wich most likely will cause the problems:public udb_encode(nickname[]) {  new enctmp[MAX_STRING];  set(enctmp,nickname);  enctmp=strreplace("_"," 00",enctmp);  enctmp=strreplace(";"," 01",enctmp);  enctmp=strreplace("!"," 02",enctmp);  enctmp=strreplace("/"," 03",enctmp);  enctmp=strreplace("\\"," 04",enctmp);  enctmp=strreplace("["," 05",enctmp);  enctmp=strreplace("]"," 06",enctmp);  enctmp=strreplace("?"," 07",enctmp);  enctmp=strreplace("."," 08",enctmp);  enctmp=strreplace("*"," 09",enctmp);  enctmp=strreplace("<"," 10",enctmp);  enctmp=strreplace(">"," 11",enctmp);  enctmp=strreplace("{"," 12",enctmp);  enctmp=strreplace("}"," 13",enctmp);  enctmp=strreplace(":"," 14",enctmp);  enctmp=strreplace("="," 15",enctmp);  return enctmp;}Functions used by the function above:strreplace(trg[],newstr[],src[]) { new repf=0; new reps1[MAX_STRING]; new reptmp[MAX_STRING]; set(reps1,src); repf = strfind(reps1,trg); reptmp[0]=0; while (repf>=0)    {		strcat(reptmp,ret_memcpy(reps1, 0, repf));		strcat(reptmp,newstr);		reps1=ret_memcpy(reps1, repf+strlen(trg), strlen(reps1)-repf);        	repf = strfind(reps1,trg);    } strcat(reptmp,reps1); return reptmp;}ret_memcpy(const source[],index=0,numbytes) {SendClientMessageToAll(0xFF0000FF,"TEST 1");  new rettmp[MAX_STRING];  new reti=0;  rettmp[0]=0;  SendClientMessageToAll(0xFF0000FF,"TEST 2");  if (index>=strlen(source)) return rettmp;  if (numbytes+index>=strlen(source)) numbytes=strlen(source)-index;  if (numbytes<=0) return rettmp;  for (reti=index;reti<numbytes+index;reti++) {	rettmp[reti-index]=source[reti];	if (source[reti]==0) return rettmp;  }  SendClientMessageToAll(0xFF0000FF,"TEST 3");  rettmp[numbytes]=0;  return rettmp;}