Event system help
#1

so I was working again on my event system from my server but this time with dialogs and to be hownest I faced so many problems in making this event system and this one of them that I couldn't fix so when I enable the event and the player join the event when he do /leaveevent he should get back to his last location and it work but the problem is if some one else joined the event and I didi leaveevent when he do leave event it don't tp him baack and some times it tp me to my last location before joining the event I hop u help me fix it here is the code
Код:
enum E_INFO
{
    EventEnabled1,
    EventEnabled2
    
}
new EventInfo[E_INFO];
new RconInfo[R_INFO];
new Eventr[MAX_PLAYERS];
new Eventd[MAX_PLAYERS];
btw every thing working fine exept the location and the 2 player get fucked up with the other location 
if(dialogid==Events)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
			case 0:
			{
			    ShowPlayerDialog(playerid,Event1,DIALOG_STYLE_LIST,"Fast And Furious","Join\nCMDS","Select","Close");
			}
			case 1:
			{
			    ShowPlayerDialog(playerid,Event2,DIALOG_STYLE_LIST,"Missioniary","Join Team 1\nJoin Team 2","Select","Close");
			}
		}
		return 1;
	}
	if(dialogid==Event2)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
			case 0:
			{
				new pos[132];
				new name[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME];
				new Float:X, Float:Y, Float:Z;
				new color;
				new skind;
				GetPlayerName(playerid, name, sizeof(name));
				GetPlayerColor(playerid, color);
				GetPlayerSkin(playerid, skind);
    			GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
				if(PlayerInfo[playerid][pEban] == 1) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are Event Banned!!");
    			if(EventInfo[EventEnabled2] == 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: This Event Is Disabled!!");
				SetPlayerPos(playerid, -1298.76, 490.54, 11.19);
				SetPlayerColor(playerid, BLUE);
				SetPlayerSkin(playerid, 73);
				GivePlayerWeapon(playerid, 31, 999);
				GivePlayerWeapon(playerid, 24, 999);
				SendClientMessage(playerid, 0x33AA33AA, "Welcome to the Missionary Team 1 !");
				format(string, sizeof(string), "%s joined Missionary Join Him /events", name);
 				SendClientMessageToAll(0xAA3333AA, string);
				Eventd[playerid]=1;
				RemovePlayerAttachedObject(playerid, 1);
			}
			case 1:
			{
				new pos[132];
				new name[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME];
				new Float:X, Float:Y, Float:Z;
				new color;
				new skind;
				GetPlayerName(playerid, name, sizeof(name));
				GetPlayerSkin(playerid, skind);
				GetPlayerColor(playerid, color);
    			GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
				if(PlayerInfo[playerid][pEban] == 1) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are Event Banned!!");
    			if(EventInfo[EventEnabled2] == 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: This Event Is Disabled!!");
				SetPlayerPos(playerid, -1385.60, 507.27, 3.03);
				SetPlayerColor(playerid, RED);
				SetPlayerSkin(playerid, 108);
				GivePlayerWeapon(playerid, 31, 999);
				GivePlayerWeapon(playerid, 24, 999);
				SendClientMessage(playerid, 0x33AA33AA, "Welcome to the Missionary Team 2 !");
				format(string, sizeof(string), "%s joined Missionary Join Him /events", name);
 				SendClientMessageToAll(0xAA3333AA, string);
				Eventd[playerid]=1;
				RemovePlayerAttachedObject(playerid, 1);
			}
		}
		return 1;
	}
	if(dialogid==Event1)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
			case 0:
			{
  				new pos[132];
				new name[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME];
				new Float:X, Float:Y, Float:Z;
				GetPlayerName(playerid, name, sizeof(name));
    			GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
				if(PlayerInfo[playerid][pEban] == 1) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are Event Banned!!");
    			if(EventInfo[EventEnabled1] == 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: This Event Is Disabled!!");
				SetPlayerPos(playerid, 4166.66, 535.80, 63.18);
				SendClientMessage(playerid, 0x33AA33AA, "Welcome to the Fast And Furious!");
				format(string, sizeof(string), "%s joined Fast And Furious Join Him /events", name);
 				SendClientMessageToAll(0xAA3333AA, string);
				Eventr[playerid]=1;
				RemovePlayerAttachedObject(playerid, 1);
			}
			case 1:
			{
			    SendClientMessage(playerid, YELLOW, "Event CMDS:leaveevent, getcar");
			}
		}
		return 1;
	}
	if(dialogid==Eventsae)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
			case 0:
			{
			  	EventInfo[EventEnabled1]=1;
				SendClientMessage(playerid, 0x0000BBAA, "Event Enabled");
				SendClientMessageToAll(0x0000BBAA, " Fast And Furious Event Have Been Enabled By An Admin [/events]");
			}
			case 1:
			{
			  	EventInfo[EventEnabled2]=1;
				SendClientMessage(playerid, 0x0000BBAA, "Event Enabled");
				SendClientMessageToAll(0x0000BBAA, "Missionary Event Have Been Enabled By An Admin [/events]");
			}
			
		}
		return 1;
	}
	if(dialogid==Eventsad)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
			case 0:
			{
			  	EventInfo[EventEnabled1]=0;
				SendClientMessage(playerid, 0x0000BBAA, "Event Disabled");
				SendClientMessageToAll(0x0000BBAA, "Fast and Furious Event Have Been Disabled By An Admin");
			}
			case 1:
			{
			  	EventInfo[EventEnabled2]=0;
				SendClientMessage(playerid, 0x0000BBAA, "Event Disabled");
				SendClientMessageToAll(0x0000BBAA, "Missionary Event Have Been Disabled By An Admin");
			}
		}
		return 1;
	}
new Ecar[MAX_PLAYERS];
CMD:getcar(playerid, params[])
{
	if(Eventr[playerid] == 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are not in event!!");
	else if(Eventd[playerid]== 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You cant use this command in this event !");
	new car;
	new string[128];
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
	if(sscanf(params, "i", car)) return SendClientMessage(playerid, 0x0000BBAA, "Usage: /getcar <Vehicle ID 400 - 611>");
	else if(car < 400 || car >611) return SendClientMessage(playerid, 0x0000BBAA, "ERROR: Connot go above or under 400-611");
	{
	if(Ecar[playerid] != 0)
	{
		DestroyVehicle(Ecar[playerid]);
	}
	    Ecar[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, 0, -1, -1, 1);
	    SendClientMessage(playerid, 0x0000BBAA, string);
	    PutPlayerInVehicle(playerid, Ecar[playerid], 0);
	}
	return 1;
}
//=============================Commands=======================================//
CMD:events(playerid, params[])
{
    if(EventInfo[EventEnabled1] == 1)
    {
    ShowPlayerDialog(playerid,Events,DIALOG_STYLE_LIST,"Server Events","Fast And Furious [Enabled]\nMissionary [Disabled]","Select","Close");
    }
    if(EventInfo[EventEnabled2] == 1)
    {
    ShowPlayerDialog(playerid,Events,DIALOG_STYLE_LIST,"Server Events","Fast And Furious [Disabled]\nMissionary [Enabled]","Select","Close");
    }
	if(EventInfo[EventEnabled1] == 1 && EventInfo[EventEnabled2] == 1)
	{
 	ShowPlayerDialog(playerid,Events,DIALOG_STYLE_LIST,"Server Events","Fast And Furious [Enabled]\nMissionary [Enabled]","Select","Close");
 	}
	if(EventInfo[EventEnabled1] == 0 && EventInfo[EventEnabled2] == 0)
	{
 	ShowPlayerDialog(playerid,Events,DIALOG_STYLE_LIST,"Server Events","Fast And Furious [Disabled]\nMissionary [Disabled]","Select","Close");
 	}
    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
    return 1;
}
CMD:leaveevent(playerid, params[])
{
    if(Eventr[playerid]== 1) //return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are not in event!!");
    {
	SetPlayerPos(pos, X, Y, Z);
	SendClientMessage(playerid, 0x33AA33AA, "Welcome back from event !");
	SetPlayerColor(playerid, color);
	Eventr[playerid]=0;
	Eventd[playerid]=0;
	if(Ecar[playerid] != 0)
	{
		DestroyVehicle(Ecar[playerid]);
	}
 	if(Bag[playerid]==1)
    {
    SetPlayerAttachedObject(playerid, 1, 3026, 1, -0.110900, -0.073500, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
	}
	}
    else if(Eventd[playerid]== 1) //return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are not in event!!");
    {
	SetPlayerPos(pos, X, Y, Z);
	SendClientMessage(playerid, 0x33AA33AA, "Welcome back from event !");
	SetPlayerColor(playerid, color);
	Eventr[playerid]=0;
	Eventd[playerid]=0;
	ResetPlayerWeapons(playerid);
	if(Ecar[playerid] != 0)
	{
		DestroyVehicle(Ecar[playerid]);
	}
 	if(Bag[playerid]==1)
    {
    SetPlayerAttachedObject(playerid, 1, 3026, 1, -0.110900, -0.073500, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
	}
	}
	else return SendClientMessage(playerid, RED, "You are not in an event");
	return 1;
}
CMD:eevent(playerid, params[])
{
    if(AdminLevel[playerid] >=1)
	{
    ShowPlayerDialog(playerid,Eventsae,DIALOG_STYLE_LIST,"Server Events","Fast And Furious\nMissionary","Select","Close");
	}
	return 1;
}
CMD:devent(playerid, params[])
{
    if(AdminLevel[playerid] >=1)
	{
	ShowPlayerDialog(playerid,Eventsad,DIALOG_STYLE_LIST,"Server Events","Fast And Furious\nMissionary","Select","Close");
	}
	return 1;
}
every thing working fine just the players bug I hop u help me.
Reply
#2

make location storing variable global instead of Float:X do it Float:X[MAX_PLAYERS] and put it at the top of your script do the same with Y and Z
Reply
#3

Quote:
Originally Posted by lackmail
Посмотреть сообщение
make location storing variable global instead of Float:X do it Float:X[MAX_PLAYERS] and put it at the top of your script do the same with Y and Z
mm can u give me the code pleasei will appreciaat it.!
Reply
#4

Quote:
Originally Posted by silverms
Посмотреть сообщение
mm can u give me the code pleasei will appreciaat it.!
Код:
//delete these lines from your script
new Float:X, Float:Y, Float:Z; 

// and put these once at the top of your script
new Float:X[MAX_PLAYERS]; 
new Float:Y[MAX_PLAYERS];
new Float:Z[MAX_PLAYERS];

//because the variables you created gets updated every time a player join event but the three lines i asked you to put at the top of your script are global variables they are created for all players because i added the "[MAX_PLAYERS]" 

//and replace all the
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);

//to 
GetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
Reply
#5

Quote:
Originally Posted by lackmail
Посмотреть сообщение
Код:
//delete these lines from your script
new Float:X, Float:Y, Float:Z; 

// and put these once at the top of your script
new Float:X[MAX_PLAYERS]; 
new Float:Y[MAX_PLAYERS];
new Float:Z[MAX_PLAYERS];

//because the variables you created gets updated every time a player join event but the three lines i asked you to put at the top of your script are global variables they are created for all players because i added the "[MAX_PLAYERS]" 

//and replace all the
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);

//to 
GetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
error 028: invalid subscript (not an array or too many subscripts): "X"
new pos[132];
new name[MAX_PLAYER_NAME], string[23 + MAX_PLAYER_NAME];
new color;
new skind;
GetPlayerName(playerid, name, sizeof(name));
GetPlayerColor(playerid, color);
GetPlayerSkin(playerid, skind);
=====GetPlayerPos(playerid, X[playerid], Y[playerid], Z[playerid]);
if(PlayerInfo[playerid][pEban] == 1) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: You Are Event Banned!!");
if(EventInfo[EventEnabled2] == 0) return SendClientMessage(playerid, 0xAA3333AA, "{6EF83C}[ERROR]: This Event Is Disabled!!");
SetPlayerPos(playerid, -1298.76, 490.54, 11.19);
SetPlayerColor(playerid, BLUE);
SetPlayerSkin(playerid, 73);
GivePlayerWeapon(playerid, 31, 999);
GivePlayerWeapon(playerid, 24, 999);
SendClientMessage(playerid, 0x33AA33AA, "Welcome to the Missionary Team 1 !");
format(string, sizeof(string), "%s joined Missionary Join Him /events", name);
SendClientMessageToAll(0xAA3333AA, string);
Eventd[playerid]=1;
RemovePlayerAttachedObject(playerid, 1);
Reply
#6

NVM I managed to fix it my seld but thank for you help
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)