A better way to do this?
#1

Hello,

I am making 'events' filterscript. So you can have events in a server. This is my first attempt at scripting something that will actually have a function. Obviously if you do /joinevent when an event doesn't exist it should tell you, here is how I made it so it restricts when you from using the command while an event isn't present. Please tell me if there is a better way to do this, or if this will even work as I have not had time to test it yet.

Код:
new JoinEvent = 0;
Код:
CMD:allowjoin(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: YOUR NOT LOGGED IN AS AN ADMIN!");
	JoinEvent = JoinEvent + 1;
	SendClientMessageToAll(COLOR_GREEN, "An event has been started! Use /joinevent to join it!");
	return 1;
}
Код:
CMD:joinevent(playerid, params[])
{
	if(JoinEvent == 0) return SendClientMessage(playerid, COLOR_GREEN, "There is not event to join!");
	if(JoinEvent == 1) return SendClientMessage(playerid, COLOR_GREEN, "You have joined the event!");
	/// SOMETHING GOES HERE
	return 1;
}
Reply
#2

That's a fine way of doing it, assuming you're also lowering that value on event end and such.
Reply
#3

Код:
#define MAX_EVENTS 10

new bool:Events[MAX_EVENTS];

CMD:allowjoin(playerid, params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "ERROR: YOUR NOT LOGGED IN AS AN ADMIN!");
        new event, string[128];
	if(sscanf(params, "i", event)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /allowjoin [Event]");
        Events[event] = true;
        format(string, sizeof(string), "An event %d has been started! Use '/joinevent %d' to join it!", event, event);
	SendClientMessageToAll(COLOR_GREEN, string);
	return 1;
}

CMD:joinevent(playerid, params[])
{
        new event;
	if(sscanf(params, "i", event)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /joinevent [Event]");
	/// SOMETHING GOES HERE
	return 1;
}
This way you can have multiple events...
Reply
#4

Delete.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)