Checkpoint Help
#1

Hello,

I'm having trouble with my mini-events system, forgive the shoddiness of the coding, I'm not an expert.

When an admin types /event 1 it tp's the admin to a location in another virtual world.. creates the mini-game objects and sets a checkpoint for him. Other players wishing to participate are asked to PM the admin and the admin does /et PLAYERID.

When a player is /et'd it sets him a checkpoint, and also sets a variable "event" to 1, so the server knows he's participating due to other checkpoints in my server. The same goes for the admin, it sets his as event = 1.

Now, when a player enters the checkpoint, they get given an in-game ticket, and re-spawned to the main game, the checkpoint is supposed to vanish and all other players re-spawn also. That's not happening, it's keeping the checkpoint and letting others win.
It sets the event variable "new event[MAX_PLAYERS];" to "event[playerid] = 0;" onplayerconnect
Any ideas? Below is my code;

/et command
pawn Код:
if(strcmp(cmd, "/et", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ERROR, "Syntax: /et (playername/id)");
                return 1;
            }
            new Float:plocx,Float:plocy,Float:plocz;
            new plo;
            plo = ReturnUser(tmp);
            if(IsPlayerNPC(plo)) return 1;
            if(IsPlayerConnected(plo))
            {
                if(plo != INVALID_PLAYER_ID)
                {
                    if(PInfo[playerid][AdminLevel] >= 5)
                    {
                        new interior = GetPlayerInterior(playerid);
                        new vw = GetPlayerVirtualWorld(playerid);
                        SetPlayerVirtualWorld(plo,vw);
                        SetPlayerInterior(plo,interior);
                        GetPlayerPos(playerid, plocx, plocy, plocz);
                        if(GetPlayerState(plo) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(plo);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                        }
                        else
                        {
                            SetPlayerPos(plo,plocx,plocy+2, plocz);
                        }
                        new sendmsg[128];
                        format(sendmsg,sizeof(sendmsg),"Administrator {1B8AE4}%s(%d) {FFFFFF}has teleported you to the event - Please wait for instructions!", PlayerName(playerid), playerid);
                        SendClientMessage(plo, COLOR_WHITE, sendmsg);
      event[plo] = 1;
                        SetPlayerCheckpoint(plo,324.6410,2542.0945,18.2410,5.0);
                        format(sendmsg,sizeof(sendmsg),"You have teleported {1B8AE4}%s(%d) {FFFFFF}to the event.", PlayerName(plo), plo);
                        SendClientMessage(playerid, COLOR_WHITE, sendmsg);
                        AdminLog(playerid, "/et", "Event Teleport", PlayerName(plo));
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "Could not find player (%d)", plo);
                SendClientMessage(playerid, COLOR_ERROR, string);
            }
        }
        return 1;
    }
/event admin command
pawn Код:
if(strcmp(cmd, "/event", true) == 0 || strcmp(cmd, "/e", true) == 0)
    {
    if(PInfo[playerid][AdminLevel] < 5) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!"); return 1; }
    new text[128];
    text = strtok(cmdtext, idx);
    if(!strlen(text)) {
        SendClientMessage(playerid, COLOR_BLUE, "* Please type /event [number] to start your event.");
        SendClientMessage(playerid, COLOR_WHITE, "[/event 1 = Door Run, 2 = None, OFF = Ends All Events]");
        return 1;
    }
    else if(strcmp(text,"1",true) == 0) {

//OBJECTS ARE HERE.. TOO MANY TO LIST

        event[playerid] = 1;
        SetPlayerVirtualWorld(playerid, 1);
        SetPlayerPos(playerid,420.9243,2504.5681,16.4844);
        SetPlayerFacingAngle(playerid,89.9681);
        SetPlayerCheckpoint(playerid,324.6410,2542.0945,18.2410,5.0);
        new stringmsg[128];
        format(stringmsg, sizeof(stringmsg), "Administrator {1B8AE4}%s(%d) {FFFFFF}has started an event. /pm (%d) to join!", PlayerName(playerid), playerid, playerid);
        SendClientMessageToAll(COLOR_WHITE, stringmsg);
        return 1;
    }
    return 1;
}
OnPlayerEnterCheckpoint snippet here
pawn Код:
if(event[playerid] == 1)
    {
        new string[72];
        format(string, sizeof(string) , "{FFFFFF}[WON] %s{FFFFFF} won the event and got a free ticket!!" ,PlayerName(playerid));
        SendClientMessageToAll(0x0088FFFF, string);
        DisablePlayerCheckpoint(playerid);
        PInfo[playerid][Tickets]=PInfo[playerid][Tickets]+1;
        ServerTickets = ServerTickets+1;
        SaveStuff();
        AdminLog(playerid, "Event Won", "Awarded Ticket", PlayerName(playerid));
        TicketLog( "Server" , PlayerName(playerid), "Event Winner");
        SetPlayerVirtualWorld(playerid, 0);
        SpawnPlayer(playerid);
        FreezePlayerForTime(playerid, 3);
        event[playerid] = 0;
    }
    return 1;
}
So yeah, if anyone can help me out a little, i'd be grateful!
Reply
#2

Polite bump? I've noticed here, that posts with a [REP+++++] type title, get the help mostly? :/
Reply
#3

Quote:
Originally Posted by twitch2k8
Посмотреть сообщение
OnPlayerEnterCheckpoint snippet here
pawn Код:
if(event[playerid] == 1)
    {
        new string[72];
        format(string, sizeof(string) , "{FFFFFF}[WON] %s{FFFFFF} won the event and got a free ticket!!" ,PlayerName(playerid));
        SendClientMessageToAll(0x0088FFFF, string);
        DisablePlayerCheckpoint(playerid);
        PInfo[playerid][Tickets]=PInfo[playerid][Tickets]+1;
        ServerTickets = ServerTickets+1;
        SaveStuff();
        AdminLog(playerid, "Event Won", "Awarded Ticket", PlayerName(playerid));
        TicketLog( "Server" , PlayerName(playerid), "Event Winner");
        SetPlayerVirtualWorld(playerid, 0);
        SpawnPlayer(playerid);
        FreezePlayerForTime(playerid, 3);
        event[playerid] = 0;
    }
    return 1;
}
Won't DisablePlayerCheckpoint(playerid); just disable the checkpoint for the player that has just finished the event first (triggering OnPlayerEnterCheckpoint), and not for other players in the event until they finish?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)