Share the variable between two files?
#1

Hello. I just got stuck to this problem.

I created a gamemode which is seperated into modules(like southclaw's scavenge & survive). But command part doesn't work.

In the core file(which loaded first), I scripted like this

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new
		cmd[32],
		params[128];

	sscanf(cmdtext, "s[32]s[128]", cmd, params);

	#if defined cmd_OnPlayerCommandText
		return cmd_OnPlayerCommandText(playerid, cmdtext[]);
	#else
		return 1;
	#endif
}
#if defined _ALS_OnPlayerCommandText
	#undef OnPlayerCommandText
#else
	#define _ALS_OnPlayerCommandText
#endif
 
#define OnPlayerCommandText cmd_OnPlayerCommandText
#if defined cmd_OnPlayerCommandText
	forward cmd_OnPlayerCommandText(playerid, cmdtext[]);
#endif
and second file, which loaded later, is scripted like this

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmd, "/ahelp", true))
	{
		return 1;
	}

	#if defined admin_OnPlayerCommandText
		return admin_OnPlayerCommandText(playerid, cmdtext);
	#else
		return 1;
	#endif
}
#if defined _ALS_OnPlayerCommandText
	#undef OnPlayerCommandText
#else
	#define _ALS_OnPlayerCommandText
#endif
 
#define OnPlayerCommandText admin_OnPlayerCommandText
#if defined admin_OnPlayerCommandText
	forward admin_OnPlayerCommandText(playerid, cmdtext[]);
#endif
and the error comes out

Код:
error 017: undefined symbol "cmd"
I understand this error, but I can't figure out how to solve this. What I want is to use cmd variable in first file in second file. Is this possible Thanks
Reply


Messages In This Thread
Share the variable between two files? - by pellstrike - 30.01.2015, 04:52
Re: Share the variable between two files? - by pellstrike - 30.01.2015, 07:56
Re: Share the variable between two files? - by DRIFT_HUNTER - 30.01.2015, 08:12
Re: Share the variable between two files? - by pellstrike - 30.01.2015, 08:47
Re: Share the variable between two files? - by pellstrike - 30.01.2015, 08:58
Re: Share the variable between two files? - by CalvinC - 30.01.2015, 09:24

Forum Jump:


Users browsing this thread: 1 Guest(s)