[HELP] Event System
#5

I made this about a year back.
pawn Код:
new Float:eventx, Float:eventy, Float:eventz, Float:Eventteamx[10], Float:Eventteamy[10], Float:Eventteamz[10], Event[MAX_PLAYERS], Eventwep, Eventammo, eventteam[MAX_PLAYERS], Float:eventoldposx[MAX_PLAYERS], Float:eventoldposy[MAX_PLAYERS], Float:eventoldposz[MAX_PLAYERS], eventneedplace[MAX_PLAYERS];

OnPlayerDeath(playerid, killerid)
{
if (Event[playerid] == 1)
    {
        Event[playerid] = 0;
        eventteam[playerid] = 0;
        SendClientMessage(playerid, 0xFFFFFFFF, "You have died, you are out of the event");
        eventneedplace[playerid] = 1;
    }
    if (Event[killerid] == 1)
    {
        SendClientMessage(killerid, 0xFFFFFFFF, "good, another down");
        return 1;
    }
}

OnPlayerSpawn(playerid)
{
    if (eventneedplace[playerid] == 1)
    {
        SetPlayerPos(playerid, eventoldposx[playerid], eventoldposy[playerid], eventoldposz[playerid]);
    }
}

new eventreward, eventhealth, eventarmor, eventvehicles, eventadmin[MAX_PLAYERS];

CMD:event(playerid, params[])
{
    new type[128], opt[128], num, pid;
    if ((PlayerInfo[playerid][pAdmin] < 1)) return 1;
    if (sscanf(params, "sz", type, opt))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event [name]");
        SendClientMessage(playerid, 0xFFFFFFFF, "Available Names: new, join, kick, team, setteam, startwep, start, end");
        SendClientMessage(playerid, 0xFFFFFFFF, "Available Names: reward, givereward, giveteamreward, health, armour, vehicles");
    }
    else if (!strcmp(type, "new", true, 3))
    {
        GetPlayerPos(playerid, eventx, eventy, eventz);
        SendClientMessage(playerid, 0xFFFFFFFF, "You have set your current pos as the event pos");
        eventadmin[playerid] = 1;
    }
    else if (eventx == 0.0) SendClientMessage(playerid, 0xFFFFFFFF, "You have to create the event first!");
    else if (!strcmp(type, "join", true, 4))
    {
        if (sscanf(opt, "u", pid)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event join [playerid]");
        else
        {
            GetPlayerPos(pid, eventoldposx[pid], eventoldposy[pid], eventoldposz[pid]);
            if((IsPlayerInAnyVehicle(pid)) && (eventvehicles == 1))
            {
                SetVehiclePos(GetPlayerVehicleID(pid), eventx, eventy, eventz);
            }
            else
            {
            SetPlayerPos(pid, eventx, eventy, eventz);
            }
            SendClientMessage(playerid, 0xFFFFFFFF, "You have Invited the player");
            SendClientMessage(pid, 0xFFFFFFFF, "You have been invited to the event!");
            SendClientMessage(pid, 0xFFFFFFFF, "Use /e to talk to others in the event");
            Event[pid] = 1;
        }
    }
    else if (!strcmp(type, "kick", true, 4))
    {
        if (sscanf(opt, "u", pid)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event kick [playerid]");
        else if (eventoldposx[pid] == 0.0) SendClientMessage(playerid, 0xFFFFFFFF, "they aren't in the event...");
        else
        {
            SetPlayerPos(pid, eventoldposx[pid], eventoldposy[pid], eventoldposz[pid]);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have kicked the player from the event");
            SendClientMessage(pid, 0xFFFFFFFF, "You have been kicked from the event!");
            Event[pid] = 0;
            eventteam[pid] = 0;
        }
    }
    else if (!strcmp(type, "setteam", true, 7))
    {
        if (sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event setteam [teamnumber]");
        else
        {
            GetPlayerPos(playerid, Eventteamx[num], Eventteamy[num], Eventteamz[num]);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have set this teams pos to your pos");
        }
    }
    else if (!strcmp(type, "team", true, 4))
    {
        if (sscanf(opt, "iu", num, pid)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event team [teamid] [playerid]");
        else if (Eventteamx[num] == 0) SendClientMessage(playerid, 0xFFFFFFFF, "You have not set a pos for this team");
        else
        {
            SetPlayerPos(pid, Eventteamx[num], Eventteamy[num], Eventteamz[num]);
            eventteam[pid] = num;
            new string[128];
            format(string, 128, "You have set the player onto team %i", num);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
            format(string, 128, "You have been set to team %i", num);
            SendClientMessage(pid, 0xFFFFFFFF, string);
        }
    }
    else if (!strcmp(type, "startwep", true, 8))
    {
        if (sscanf(opt, "ii", num, pid)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event startwep [wepid] [ammo]");
        else if (num > 45 || num < 0 || pid > 1000) SendClientMessage(playerid, 0xFFFFFFFF, "Your loco");
        else
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Weapon and ammo set");
            Eventwep = num;
            Eventammo = pid;
        }
    }
    else if (!strcmp(type, "start", true, 5))
    {
        SendClientMessageToAll(0xFFFFFFFF, "The event has been started!");
        if (Eventwep == 0) return 1;
        else
        {
            for(new i; i < 200; i++)
            {
                if (Event[i] == 1)
                {
                    if (eventhealth != 0)
                    {
                        SetPlayerHealth(i, eventhealth);
                    }
                    SetPlayerArmour(i, eventarmor);
                    PlayerInfo[i][pArmour] = eventarmor;
                    GivePlayerWeapon(i, Eventwep, Eventammo);
                    if (eventteam[i] != 0) SetPlayerPos(playerid, Eventteamx[eventteam[i]], Eventteamy[eventteam[i]], Eventteamz[eventteam[i]]);
                }
            }
        }
    }
    else if (!strcmp(type, "end", true, 3))
    {
        for(new i; i < 200; i++)
        {
            if (Event[i] == 1)
            {
                Event[i] = 0;
                eventteam[i] = 0;
                eventx = 0.0;
                SetPlayerPos(i, eventoldposx[i], eventoldposy[i], eventoldposz[i]);
            }
        }
        SendClientMessageToAll(0xFFFFFFFF, "Event has been ended!");
    }
    else if (!strcmp(type, "reward", true, 6))
    {
        if (sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event reward [amount]");
        else if (num < 1 || num > 50000) SendClientMessage(playerid, 0xFFFFFFFF, "you are loco");
        else
        {
            eventreward = num;
            SendClientMessage(playerid, 0xFFFFFFFF, "reward set");
        }
    }
    else if (!strcmp(type, "giveteamreward", true, 14))
    {
        if (sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event giveteamreward [teamid]");
        else if (num > 0 || num < 10) SendClientMessage(playerid, 0xFFFFFFFF, "invalid team id");
        else if (eventreward == 0) SendClientMessage(playerid, 0xFFFFFFFF, "No reward set");
        else
        {
            for(new i; i < 200; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if (eventteam[i] == num)
                    {
                        GivePlayerMoneyKrayzie(i, eventreward);
                        SendClientMessage(i, 0xFFFFFFFF, "you have recived the team reward");
                    }
                }
            }
            SendClientMessage(playerid, 0xFFFFFFFF, "You have given the team the reward");
        }
    }
    else if(!strcmp(type, "givereward", true, 10))
    {
        if (sscanf(opt, "i", pid)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event givereward [playerid]");
        else if (!IsPlayerConnected(pid)) SendClientMessage(playerid, 0xFFFFFFFF, "User not connected");
        else if (eventreward == 0) SendClientMessage(playerid, 0xFFFFFFFF, "No reward set");
        else
        {
            GivePlayerMoneyKrayzie(pid, eventreward);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have given the reward");
            SendClientMessage(pid, 0xFFFFFFFF, "You have received the reward");
        }
    }
    else if(!strcmp(type, "health", true, 6))
    {
        if(sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event health [health amount]");
        else if (num < 1 || num > 10000) SendClientMessage(playerid, 0xFFFFFFFF, "loco maniac, trying to kill them?");
        else
        {
            eventhealth = num;
            SendClientMessage(playerid, 0xFFFFFFFF, "Event health set");
        }
       
    }
    else if(!strcmp(type, "armour", true, 6))
    {
        if(sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event armor [armor amount]");
        else if (num < 0) SendClientMessage(playerid, 0xFFFFFFFF, "you can't do that...");
        else
        {
            eventarmor = num;
            SendClientMessage(playerid, 0xFFFFFFFF, "Event armor set");
        }
    }
    else if (!strcmp(type, "vehicles", true, 8))
    {
        if (sscanf(opt, "i", num)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /event vehicles [disable(0), enable(1)]");
        else
        {
            eventvehicles = num;
            SendClientMessage(playerid, 0xFFFFFFFF, "vehicles allowed or disallowed, note: no teams allowed");
        }
    }
    return 1;
}

CMD:e(playerid, params[])
{
    new textmsg[128], msg[128];
    if (PlayerInfo[playerid][pAdmin] >= 1)
    {
        if (sscanf(params, "s", textmsg)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /e [text]");
        format(msg, sizeof(msg), "Event Admin %s: %s", pName[playerid], textmsg);
        for(new i; i < 200; i++)
        {
            if(Event[i] == 1 || eventadmin[i] == 1)
            {
                SendClientMessage(i, 0x00FFFFFF, msg);
            }
        }
    }
    else
    {
        if (sscanf(params, "s", textmsg)) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /e [text]");
        if (Event[playerid] == 0) return 1;
        format(msg, sizeof(msg), "Event %s: %s", pName[playerid], textmsg);
        for(new i; i < 200; i++)
        {
            if(Event[i] == 1 || eventadmin[i] == 1)
            {
                if (eventteam[playerid] == eventteam[i])
                {
                    SendClientMessage(i, 0x80FFFFFF, msg);
                }
            }
        }
    }
    return 1;
}
it is old so it uses old sscanf
Reply


Messages In This Thread
[HELP] Event System - by Dudits - 01.08.2010, 02:04
Re: [HELP] Event System - by Dudits - 01.08.2010, 05:00
Re: [HELP] Event System - by Dudits - 01.08.2010, 12:11
Re: [HELP] Event System - by Vince - 01.08.2010, 13:24
Re: [HELP] Event System - by Daren_Jacobson - 01.08.2010, 14:53
Re: [HELP] Event System - by Dudits - 02.08.2010, 00:55
Re: [HELP] Event System - by PotH3Ad - 02.08.2010, 01:04
Re: [HELP] Event System - by Dudits - 02.08.2010, 01:09
Re: [HELP] Event System - by Dudits - 02.08.2010, 02:44
Re: [HELP] Event System - by Dudits - 02.08.2010, 05:59

Forum Jump:


Users browsing this thread: 1 Guest(s)