Help for errors and warnings -.- [+REP]
#10

Here's a small script I have just made that should show you how you create a simple event system with strcmp. You can edit it however you like.

pawn Код:
#include <a_samp>

new InEvent[MAX_PLAYERS];
new EventRunning;
new Float:EventX, Float:EventY, Float:EventZ, Float:EventAng;
new EventInt, EventVW;

public OnGameModeInit() //Or OnFilterScriptInit if you're using a filterscript.
{
    EventRunning = 0;
    return 1;
}

public OnPlayerConnect(playerid)
{
    InEvent[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(InEvent[playerid] == 1)
    {
        SendClientMessage(playerid, 0xFF0000FF, "You Have Left The Event Because You Were Killed.");
        InEvent[playerid] = 0;
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/joinevent", true) == 0)
    {
        if(InEvent[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already In The Event!");
        if(EventRunning == 0) return SendClientMessage(playerid, 0xFF0000FF, "There Is Currently No Events Running.");
        SetPlayerInterior(playerid, EventInt);
        SetPlayerPos(playerid, EventX, EventY, EventZ);
        SetPlayerFacingAngle(playerid, EventAng);
        SetPlayerVirtualWorld(playerid, EventVW);
        SendClientMessage(playerid, 0x00FF00FF, "You Have Joined The Event.");
        return 1;
    }

    if(strcmp(cmdtext, "/leaveevent", true) == 0)
    {
        if(InEvent[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not In An Event!");
        if(EventRunning == 0) return SendClientMessage(playerid, 0xFF0000FF, "There Is Currently No Events Running.");
        SpawnPlayer(playerid);
        InEvent[playerid] = 0;
        SendClientMessage(playerid, 0xFF0000FF, "You Have Left The Event.");
        return 1;
    }
    if(strcmp(cmdtext, "/beginevent", true) == 0)
    {
        if(EventRunning == 1) return SendClientMessage(playerid, 0xFF0000FF, "There Is Already An Event Happening.");
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only Administrators Can Start Events!");
        new Float:x, Float:y, Float:z;
        new Float:ang;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, ang);
        EventX = x;
        EventY = y;
        EventZ = z;
        EventAng = ang;
        EventRunning = 1;
        InEvent[playerid] = 1;
        new string[90];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"Administrator %s Has Started An Event. Type /JOINEVENT To Join.",name);
        SendClientMessageToAll(0x00FF00FF, string);
        return 1;
    }
    if(strcmp(cmdtext, "/stopevent", true) == 0)
    {
        if(EventRunning == 0) return SendClientMessage(playerid, 0xFF0000FF, "There Is Currently No Events Running.");
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only Administrators Can End Events!");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(InEvent[i] == 1)
                {
                    SpawnPlayer(i);
                    InEvent[i] = 0;
                }
            }
        }
        EventRunning = 0;
        new string[60];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"Administrator %s Has Ended The Event.",name);
        SendClientMessageToAll(0x00FF00FF, string);
        return 1;
    }
    return SendClientMessage(playerid, 0xFF0000FF, "This Command Does Not Exist.");
}
Reply


Messages In This Thread
Help for errors and warnings -.- [+REP] - by pblbms - 19.09.2012, 18:36
Re: Help for errors and warnings -.- [+REP] - by RLGaming - 19.09.2012, 18:39
Re: Help for errors and warnings -.- [+REP] - by pblbms - 19.09.2012, 18:44
Re: Help for errors and warnings -.- [+REP] - by pblbms - 19.09.2012, 20:22
Re: Help for errors and warnings -.- [+REP] - by pblbms - 20.09.2012, 09:41
Re: Help for errors and warnings -.- [+REP] - by pblbms - 20.09.2012, 11:38
Re: Help for errors and warnings -.- [+REP] - by pblbms - 20.09.2012, 12:49
Re: Help for errors and warnings -.- [+REP] - by clarencecuzz - 20.09.2012, 12:51
Re: Help for errors and warnings -.- [+REP] - by pblbms - 20.09.2012, 13:01
Re: Help for errors and warnings -.- [+REP] - by clarencecuzz - 20.09.2012, 13:18

Forum Jump:


Users browsing this thread: 1 Guest(s)