SA-MP Forums Archive
event system help - 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: event system help (/showthread.php?tid=664879)



event system help - bosmania - 14.03.2019

im making an event system and i want to do it like this and i don't kniw how

When an admin is using /startevent,i want to save his position

When a player types /tpevent i want him teleported to the admin's saved position

What i did so far teleports a player to the admin's position but its not the same position for everyone ,like,it teleports each player to the admin's position in that moment,when the player types the command

CMDtartevent(playerid, params[])
{
EventOrganizer[playerid] = 1;
return 1;
}


CMD:tpevent(playerid, params[])
{
foreach(new i : Player){
if(EventOrganizer[i] == 1){
GetPlayerPos(i, Float, Float:y, Float:z);
}
SetPlayerPos(playerid, Float, Float:y, Float:z);
}

return 1;
}


Re: event system help - TheToretto - 14.03.2019

pawn Код:
enum E_EVENT_INFO
{
    Float:eventX,
    Float:eventY,
    Float:eventZ,
    bool:eventOrganizer
}

new EventInfo[MAX_PLAYERS][E_EVENT_INFO];

CMD:startevent(playerid, params[])
{  
    foreach(new i : Player){
        if(EventInfo[i][eventOrganizer])
            // an event is already started, return something
    }
    EventInfo[playerid][eventOrganizer] = true;
    GetPlayerPos(playerid, EventInfo[playerid][eventX], EventInfo[playerid][eventY], EventInfo[playerid][eventZ]);
    return 1;
}


CMD:tpevent(playerid, params[])
{
    foreach(new i : Player){
        if(!EventInfo[i][eventOrganizer]) continue;
       
        return SetPlayerPos(playerid, EventInfo[i][eventX], EventInfo[i][eventY], EventInfo[i][eventZ]);
    }
    // no one has started any event
    return 1;
}
Allows only one event at once


Re: event system help - bosmania - 14.03.2019

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
pawn Код:
enum E_EVENT_INFO
{
    Float:eventX,
    Float:eventY,
    Float:eventZ,
    bool:eventOrganizer
}

new EventInfo[MAX_PLAYERS][E_EVENT_INFO];

CMD:startevent(playerid, params[])
{  
    foreach(new i : Player){
        if(EventInfo[i][eventOrganizer])
            // an event is already started, return something
    }
    EventInfo[playerid][eventOrganizer] = true;
    return 1;
}


CMD:tpevent(playerid, params[])
{
    foreach(new i : Player){
        if(!EventInfo[i][eventOrganizer]) continue;
       
        return SetPlayerPos(playerid, EventInfo[i][eventX], EventInfo[i][eventY], EventInfo[i][eventZ]);
    }
    // no one has started any event
    return 1;
}
Allows only one event at once
okay so i should set the event pos(x,y,z) the event organizer's pos?


Re: event system help - TheToretto - 14.03.2019

Quote:
Originally Posted by bosmania
Посмотреть сообщение
okay so i should set the event pos(x,y,z) the event organizer's pos?
Yup.

Edit: Lol actually add this line, totally forgot about it

pawn Код:
GetPlayerPos(playerid, EventInfo[playerid][eventX], EventInfo[playerid][eventY], EventInfo[playerid][eventZ]);



Re: event system help - bosmania - 14.03.2019

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Yup.

Edit: Lol actually add this line, totally forgot about it

pawn Код:
GetPlayerPos(playerid, EventInfo[playerid][eventX], EventInfo[playerid][eventY], EventInfo[playerid][eventZ]);
And could you please help me with a restriction,like if 10 people have teleported to the event,i want the others to not be able to tp anymore,to tell them something like the event slots are full


Re: event system help - Gameluner - 14.03.2019

Quote:

help me with a restriction,like if 10 people have teleported to the event,i want the others to not be able to tp anymore

Код:
new playersteleported;
CMD:tpevent(playerid, params[])
{
foreach(new i : Player){
if(EventOrganizer[i] == 1){
GetPlayerPos(i, Float, Float:y, Float:z);
}
if(playersteleported > 11) return SCM(playerid, -1, "u can't teleport anymore");

SetPlayerPos(playerid, Float, Float:y, Float:z);
}
playersteleported++
return 1;
}



Re: event system help - SymonClash - 14.03.2019

Quote:
Originally Posted by Gameluner
Посмотреть сообщение
//Code
There is no need to place the "playersteleported" check inside the loop.

And he asked for a limit of 10, not more than 11.

pawn Код:
new PlayersInEvent = 0;

CMD:tpevent(playerid, params[])
{
    if(PlayersInEvent >= 10) return SCM(playerid, -1, "Event is full.");
   
    foreach(new i : Player)
    {
        if(EventOrganizer[i] == 1) GetPlayerPos(i, Float, Float:y, Float:z);
    }
   
    SetPlayerPos(playerid, Float, Float:y, Float:z);

    PlayersInEvent++
    return 1;
}