SA-MP Forums Archive
A better way to do this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A better way to do this? (/showthread.php?tid=370455)



A better way to do this? - BittleRyan - 20.08.2012

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;
}



Re: A better way to do this? - PrawkC - 20.08.2012

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


Re: A better way to do this? - Shetch - 20.08.2012

Код:
#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...


Re: A better way to do this? - avivelkayam - 20.08.2012

Delete.