[HELP] Event System
#1

I'm trying to make an event system, everything is working fine but this.
I cannot enter anything after the "/setevent weapons" because for some reason it doesn't read it...

pawn Код:
CMD:setevent(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(EventInfo[eStarted]) return SendClientMessage(playerid, COLOR_GRAD1, "You have already started the event.");
        new eventrelated[24];
        new slot[4];
        new gunid;
        new message[32];
        if(sscanf(params, "s", eventrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent [position - weapons]");
        if(!strcmp(eventrelated, "position", true))
        {
            EventInfo[eInt] = GetPlayerInterior(playerid);
            GetPlayerPos(playerid, EventInfo[eX], EventInfo[eY], EventInfo[eZ]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the event's starting position.");
        }
        else if(!strcmp(eventrelated, "weapons", true))
        {
            if(sscanf(params, "sii", eventrelated, gunid, slot)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent weapons [gun id] [slot(1-3)]");
            if(!strcmp(slot, "1", true))
            {
                EventInfo[eSlot1] = gunid;
                format(message, sizeof(message), "You have set the event's slot 1 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "2", true))
            {
                EventInfo[eSlot2] = gunid;
                format(message, sizeof(message), "You have set the event's slot 2 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "3", true))
            {
                EventInfo[eSlot3] = gunid;
                format(message, sizeof(message), "You have set the event's slot 3 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
        }
    }
    return 1;
}
Note: It doesn't even send the ClientMessage of the slot
Reply
#2

Still need help.
Reply
#3

Bumpz0rz
Reply
#4

if(slot == 1) or switch(slot) should work. Don't use stringcompare for integers.
Reply
#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
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
if(slot == 1) or switch(slot) should work. Don't use stringcompare for integers.
Still same problem, doesn't do anything when I enter the gunid.
I also tried switching between gunid & slot but nothing happens.
Simply nothing happens when I enter anything after /setevent weapons

pawn Код:
CMD:setevent(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(EventInfo[eStarted]) return SendClientMessage(playerid, COLOR_GRAD1, "You have already started the event.");
        new eventrelated[24];
        new slot;
        new gunid;
        new message[32];
        if(sscanf(params, "s", eventrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent [position - weapons]");
        if(!strcmp(eventrelated, "position", true))
        {
            EventInfo[eInt] = GetPlayerInterior(playerid);
            GetPlayerPos(playerid, EventInfo[eX], EventInfo[eY], EventInfo[eZ]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the event's starting position.");
        }
        else if(!strcmp(eventrelated, "weapons", true))
        {
            if(sscanf(params, "sii", eventrelated, gunid, slot)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent weapons [gun id] [slot(1-3)]");
            if(slot == 1)
            {
                EventInfo[eSlot1] = gunid;
                format(message, sizeof(message), "You have set the event's slot 1 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(slot == 2)
            {
                EventInfo[eSlot2] = gunid;
                format(message, sizeof(message), "You have set the event's slot 2 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(slot == 3)
            {
                EventInfo[eSlot3] = gunid;
                format(message, sizeof(message), "You have set the event's slot 3 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
        }
    }
    return 1;
}
@ Daren: Well, I appreciate that but I don't really like your system :S
Reply
#7

Try this

pawn Код:
CMD:setevent(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(EventInfo[eStarted]) return SendClientMessage(playerid, COLOR_GRAD1, "You have already started the event.");
        new eventrelated[24];
        new slot[4];
        new gunid;
        new message[32];
        if(sscanf(params, "s", eventrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent [position - weapons]");
        if(!strcmp(eventrelated, "position", true, 8))
        {
            EventInfo[eInt] = GetPlayerInterior(playerid);
            GetPlayerPos(playerid, EventInfo[eX], EventInfo[eY], EventInfo[eZ]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the event's starting position.");
        }
        else if(!strcmp(eventrelated, "weapons", true, 7))
        {
            if(sscanf(params, "sii", eventrelated, gunid, slot)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent weapons [gun id] [slot(1-3)]");
            if(!strcmp(slot, "1", true, 1))
            {
                EventInfo[eSlot1] = gunid;
                format(message, sizeof(message), "You have set the event's slot 1 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "2", true, 1))
            {
                EventInfo[eSlot2] = gunid;
                format(message, sizeof(message), "You have set the event's slot 2 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "3", true, 1))
            {
                EventInfo[eSlot3] = gunid;
                format(message, sizeof(message), "You have set the event's slot 3 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
        }
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
Try this

pawn Код:
CMD:setevent(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(EventInfo[eStarted]) return SendClientMessage(playerid, COLOR_GRAD1, "You have already started the event.");
        new eventrelated[24];
        new slot[4];
        new gunid;
        new message[32];
        if(sscanf(params, "s", eventrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent [position - weapons]");
        if(!strcmp(eventrelated, "position", true, 8))
        {
            EventInfo[eInt] = GetPlayerInterior(playerid);
            GetPlayerPos(playerid, EventInfo[eX], EventInfo[eY], EventInfo[eZ]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the event's starting position.");
        }
        else if(!strcmp(eventrelated, "weapons", true, 7))
        {
            if(sscanf(params, "sii", eventrelated, gunid, slot)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent weapons [gun id] [slot(1-3)]");
            if(!strcmp(slot, "1", true, 1))
            {
                EventInfo[eSlot1] = gunid;
                format(message, sizeof(message), "You have set the event's slot 1 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "2", true, 1))
            {
                EventInfo[eSlot2] = gunid;
                format(message, sizeof(message), "You have set the event's slot 2 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "3", true, 1))
            {
                EventInfo[eSlot3] = gunid;
                format(message, sizeof(message), "You have set the event's slot 3 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
        }
    }
    return 1;
}
I can enter the gunid now, but nothing happens when I enter the slot
Edit: I removed the ! and it sent the message, lemme test if this works.
2x Edit: Yup works, <3
3x Edit: Well it only adds weapons to slot 1 when the !'s are removed, here's my code.

pawn Код:
CMD:setevent(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(EventInfo[eStarted]) return SendClientMessage(playerid, COLOR_GRAD1, "You have already started the event.");
        new eventrelated[24];
        new slot[4];
        new gunid;
        new message[128];
        if(sscanf(params, "s", eventrelated)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent [position - weapons]");
        if(!strcmp(eventrelated, "position", true, 8))
        {
            EventInfo[eInt] = GetPlayerInterior(playerid);
            GetPlayerPos(playerid, EventInfo[eX], EventInfo[eY], EventInfo[eZ]);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the event's starting position.");
        }
        else if(!strcmp(eventrelated, "weapons", true, 7))
        {
            if(sscanf(params, "sii", eventrelated, gunid, slot)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setevent weapons [gun id] [slot(1-3)]");
            if(!strcmp(slot, "1", true, 1))
            {
                EventInfo[eSlot1] = gunid;
                format(message, sizeof(message), "You have set the event's slot 1 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "2", true, 1))
            {
                EventInfo[eSlot2] = gunid;
                format(message, sizeof(message), "You have set the event's slot 2 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
            else if(!strcmp(slot, "3", true, 1))
            {
                EventInfo[eSlot3] = gunid;
                format(message, sizeof(message), "You have set the event's slot 3 gun to %s", gunid);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, message);
            }
        }
    }
    return 1;
}
Reply
#9

Bump, still need help.
Reply
#10

Bumpz0rz
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)