Which one of these scripts are better to use? | I also need help
#1

Ok, so i've been working on a faction system, as im new to scripting and i feel its a good way to learn. I have 2 examples i made, and i was wondering which ones would be better to use...
these are them:

V1:
pawn Код:
#include <a_samp>
new Army[MAX_PLAYERS];
new IsPlayerInFaction[MAX_PLAYERS];
new Cop[MAX_PLAYERS];
new Gov[MAX_PLAYERS];
new Swat[MAX_PLAYERS];
new Ss[MAX_PLAYERS];
new Medic[MAX_PLAYERS];
new id;
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    LimitGlobalChatRadius(Float:20);
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(heal,4,cmdtext);
    dcmd(wanted,6,cmdtext);
    dcmd(jail,4,cmdtext);
    if (strcmp("/joingoverment", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x99CCCCAA);
        IsPlayerInFaction[playerid] = 1;
        Gov[playerid] = 1;
        SendClientMessage(playerid,0x99CCCCAA,"You have joined the Goverment");
        }
        return 1;
    }
    if (strcmp("/joinarmy", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x006633AA);
        IsPlayerInFaction[playerid] = 1;
        Army[playerid] = 1;
        SendClientMessage(playerid,0x006633AA,"You have joined the Army");
        }
        return 1;
    }
    if (strcmp("/joinswat", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x330099AA);
        IsPlayerInFaction[playerid] = 1;
        Swat[playerid] = 1;
        SendClientMessage(playerid,0x330099AA,"You have joined the S.W.A.T Team.");
        }
        return 1;
    }
    if (strcmp("/joinpolice", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x3300FFAA);
        IsPlayerInFaction[playerid] = 1;
        Cop[playerid] = 1;
        SendClientMessage(playerid,0x3300FFAA,"You have joined the LSPD.");
        }
        return 1;
    }
    if (strcmp("/joinss", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x000066AA);
        IsPlayerInFaction[playerid] = 1;
        Ss[playerid] = 1;
        SendClientMessage(playerid,0x000066AA,"You have joined the Secret Service");
        }
        return 1;
    }
    if (strcmp("/joinems", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0xFFCCFFAA);
        IsPlayerInFaction[playerid] = 1;
        Medic[playerid] = 1;
        SendClientMessage(playerid,0xFFCCFFAA,"You have joined the Emergency Medical Service.");
        }
        return 1;
    }
    if (strcmp("/factions", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid,0x00FF00AA,"{66FF66}|FACTIONS|{00FF00} The Army, Los Santos Police Department (LSPD), Emergency Medical Service (EMS)");
        SendClientMessage(playerid,0x00FF00AA,"{66FF66}|FACTIONS|{00FF00} Special Weapons And Tactics (S.W.A.T), Secret Service (SS)");
        return 1;
    }
    if (strcmp("/quitfaction", cmdtext, true, 10) == 0)
    {
        if(Army[playerid] == 1 || Swat[playerid] == 1 || Cop[playerid] == 1 || Ss[playerid] == 1 || Medic[playerid] == 1)
        {
            SetPlayerColor(playerid, 0xFFFFFFAA);
            SendClientMessage(playerid,0xFFFFCCAA,"You have quit your faction");
            Army[playerid] = 0;
            Swat[playerid] = 0;
            Cop[playerid] = 0;
            Ss[playerid] = 0;
            Medic[playerid] = 0;
            IsPlayerInFaction[playerid] = 0;
        }
        else if(Army[playerid] == 0 || Swat[playerid] == 0 || Cop[playerid] == 0 || Ss[playerid] == 0 || Medic[playerid] == 0)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"You aren't in a faction");
        }
        return 1;
    }
    if (strcmp("/Factionhelp", cmdtext, true, 10) == 0)
    {
        if(Army[playerid] == 1 || Swat[playerid] == 1 || Cop[playerid] == 1 || Ss[playerid] == 1)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"Commands: /jail | /wanted");
        }
        if(Medic[playerid] == 1)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"Commands: /heal");
        }
        return 1;
    }
    return 1;
}
dcmd_heal(playerid, params[])
{
    if (strlen(params))
    {
        id = strval(params[0]);
        if (IsPlayerConnected(id))
        {
            if(Medic[playerid] == 1)
            {
                SetPlayerHealth(id,100);
                new pName[24];
                new string[265];
                GetPlayerName(playerid,"pName",sizeof(pName));
                format(string,sizeof(string),"MEDIC:You got healed by Medic %s",pName);
                SendClientMessage(id,0x00FF00AA,string);
            }
            else
            {
                SendClientMessage(playerid,0x00FF00AA,"SERVER:You dont have permission to this command!");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "SERVER:Usage /heal [ID]");
    }
    return 1;
}
dcmd_wanted(playerid, params[])
{
    if (strlen(params))
    {
        new lvl;
        id = strval(params[0]);
        lvl = strval(params[1]);
        if (IsPlayerConnected(playerid))
        {
            if(Army[playerid] == 1 || Swat[playerid] == 1 || Cop[playerid] == 1 || Ss[playerid] == 1)
            {
                SetPlayerWantedLevel(id,lvl);
            }
            else
            {
                SendClientMessage(playerid,0x00FF00AA,"SERVER:You dont have permission to this command!");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    return 1;
}


dcmd_jail(playerid, params[])
{
    if (strlen(params))
    {
        new time;
        id = strval(params[0]);
        time = strval(params[1]);
        if (IsPlayerConnected(id))
        {
            if(Army[playerid] == 1 || Swat[playerid] == 1 || Cop[playerid] == 1 || Ss[playerid] == 1)
            {
                new Float:x;
                new Float:y;
                new Float:z;
                new string[265];
                GetPlayerPos(playerid,Float:x,Float:y,Float:z);
                SetPlayerPos(id,Float:x,Float:y,Float:z);
                SetTimer("jail",time+000,0);
                format(string,sizeof(string),"Jail:You got jailed for %s ",time);
                SendClientMessage(id,0x00FF00AA,string);
            }
            else
            {
                SendClientMessage(playerid,0xFF0000AA,"You dont have permission for this commands");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: /jail <playerid> <seconds>");
    }
    return 1;
}
V1.1:
pawn Код:
#include <a_samp>
#define faction_civ 0
#define faction_army   1
new IsPlayerInFaction[MAX_PLAYERS];
#define faction_lspd   2
#define faction_gov   3
#define faction_swat   4
new pFaction[MAX_PLAYERS];
#define faction_ss   5
#define faction_medic   6
new id;
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

main()
{
    print("\n----------------------------------");
    print(" Faction V1.1 by DaRealz");
    print("----------------------------------\n");
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(heal,4,cmdtext);
    dcmd(wanted,6,cmdtext);
    dcmd(jail,4,cmdtext);
    if (strcmp("/joingoverment", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x99CCCCAA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_gov;
        SendClientMessage(playerid,0x99CCCCAA,"You have joined the Goverment");
        }
        return 1;
    }
    if (strcmp("/joinarmy", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x006633AA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_army;
        SendClientMessage(playerid,0x006633AA,"You have joined the Army");
        }
        return 1;
    }
    if (strcmp("/joinswat", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x330099AA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_swat;
        SendClientMessage(playerid,0x330099AA,"You have joined the S.W.A.T Team.");
        }
        return 1;
    }
    if (strcmp("/joinpolice", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x3300FFAA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_lspd;
        SendClientMessage(playerid,0x3300FFAA,"You have joined the LSPD.");
        }
        return 1;
    }
    if (strcmp("/joinss", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0x000066AA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_ss;
        SendClientMessage(playerid,0x000066AA,"You have joined the Secret Service");
        }
        return 1;
    }
    if (strcmp("/joinems", cmdtext, true, 10) == 0)
    {
        if (IsPlayerInFaction[playerid] == 1)
        {
            SendClientMessage(playerid, 0x00FF00AA,"You are already in a faction !");
        }
        else
        {
        SetPlayerColor(playerid, 0xFFCCFFAA);
        IsPlayerInFaction[playerid] = 1;
        pFaction[playerid] = faction_medic;
        SendClientMessage(playerid,0xFFCCFFAA,"You have joined the Emergency Medical Service.");
        }
        return 1;
    }
    if (strcmp("/factions", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid,0x00FF00AA,"{66FF66}|FACTIONS|{00FF00} The Army, Los Santos Police Department (LSPD), Emergency Medical Service (EMS)");
        SendClientMessage(playerid,0x00FF00AA,"{66FF66}|FACTIONS|{00FF00} Special Weapons And Tactics (S.W.A.T), Secret Service (SS)");
        return 1;
    }
    if (strcmp("/quitfaction", cmdtext, true, 10) == 0)
    {
        if(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss || pFaction[playerid] == faction_medic)
        {
            SetPlayerColor(playerid, 0xFFFFFFAA);
            SendClientMessage(playerid,0xFFFFCCAA,"You have quit your faction");
            pFaction[playerid] = faction_civ;
            IsPlayerInFaction[playerid] = 0;
        }
        else if(pFaction[playerid] == faction_civ)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"You aren't in a faction");
        }
        return 1;
    }
    if (strcmp("/Factionhelp", cmdtext, true, 10) == 0)
    {
        if(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"Commands: /jail | /wanted");
        }
        if(pFaction[playerid] == faction_medic)
        {
            SendClientMessage(playerid,0xFFFFCCAA,"Commands: /heal");
        }
        return 1;
    }
    return 1;
}
dcmd_heal(playerid, params[])
{
    if (strlen(params))
    {
        id = strval(params[0]);
        if (IsPlayerConnected(id))
        {
            if(pFaction[playerid] == faction_medic)
            {
                SetPlayerHealth(id,100);
                new pName[24];
                new string[265];
                GetPlayerName(playerid,"pName",sizeof(pName));
                format(string,sizeof(string),"MEDIC:You got healed by Medic %s",pName);
                SendClientMessage(id,0x00FF00AA,string);
            }
            else
            {
                SendClientMessage(playerid,0x00FF00AA,"SERVER:You dont have permission to this command!");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "SERVER:Usage /heal [ID]");
    }
    return 1;
}
dcmd_wanted(playerid, params[])
{
    if (strlen(params))
    {
        new lvl;
        id = strval(params[0]);
        lvl = strval(params[1]);
        if (IsPlayerConnected(playerid))
        {
            if(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
            {
                SetPlayerWantedLevel(id,lvl);
            }
            else
            {
                SendClientMessage(playerid,0x00FF00AA,"SERVER:You dont have permission to this command!");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    return 1;
}


dcmd_jail(playerid, params[])
{
    if (strlen(params))
    {
        new time;
        id = strval(params[0]);
        time = strval(params[1]);
        if (IsPlayerConnected(id))
        {
            if(pFaction[playerid] == faction_army || pFaction[playerid] == faction_swat || pFaction[playerid] == faction_lspd || pFaction[playerid] == faction_ss)
            {
                new Float:x;
                new Float:y;
                new Float:z;
                new string[265];
                GetPlayerPos(playerid,Float:x,Float:y,Float:z);
                SetPlayerPos(id,Float:x,Float:y,Float:z);
                SetTimer("jail",time+000,0);
                format(string,sizeof(string),"Jail:You got jailed for %s ",time);
                SendClientMessage(id,0x00FF00AA,string);
            }
            else
            {
                SendClientMessage(playerid,0xFF0000AA,"You dont have permission for this commands");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: /jail <playerid> <seconds>");
    }
    return 1;
}
I also need help with a rank system... how might i make a rank system for each of the factions? (up to 6 ranks).
I also need help with a /makeleader command if possible.....

Also, if you have any suggestion to make this better (with code if possbile) please don't hesitate to tell me.

Thanks for help if you can,
DaRealz

PS: my English Isnt Good
PSS: Im new to scripting as i told you so... yea...

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
I should opt for the second one, anyway i don't think think that you made it.
Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
The second one is much better because it doesn't require making multiple 500 sized cells.
I thought so
Reply
#2

The second one is much better because it doesn't require making multiple 500 sized cells.
Reply
#3

I should opt for the second one, anyway i don't think think that you made it.
Reply
#4

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
I should opt for the second one, anyway i don't think think that you made it.
I started off with the first one, which i edited up with an already downloaded one, that sucked. So i didnt make the /heal, /wanted, or /jail, i just started off with one and edited it since im new.
PS: Second one, i agree, just wanted to make sure.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)