[Tutorial] Making a simple Organization Script (Noob-Friendly).
#1

First of all, my name is Rudyy . Im a scripter.
Lets start with the tutorial.

Today i am going to teach some of you who are still finding Organization script.

First, we must have dini.inc(Optional) [For saving files].

pawn Код:
#include <a_samp>
#include <dini>
#include <dudb>
After that, we will need to define (Member , Leader , ect...)
pawn Код:
new Member[MAX_PLAYERS];
new Leader[MAX_PLAYERS];
new IsInOrg[MAX_PLAYERS];
new IsLaw[MAX_PLAYERS];
Next, Lets add a setleader command. Imagine i want my org id to be 1.
This is your OnPlayerCommandText
pawn Код:
new cmd[256];
 new idx;
 cmd = strtok(cmdtext, idx);

    if (streq(cmd,"/setleader1"))
{
    if(!strlen(cmdtext[12]))
    {
        SendClientMessage(playerid, red, "Usage: /setleader1 [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[12]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
        format(str, 123, "Admin %s has set your the leader of organization Rudyy's Gang.", pName);
        SendClientMessage(ID,COLOR_LIGHTBLUE, str);
        SetPlayerColor(ID, 0x00C300FF); // Color
        GivePlayerWeapon(ID,28,5000); // Weapon1
        GivePlayerWeapon(ID,1,-1); // Weapon 2
        IsInOrg[ID] = 1; // This tells that the user is already in an organization.
        Member[ID] = 1; //This is org id, forexample my org id i want is 1 , so i will put 1, if i want it 2 , i will put 2. Note; do not duplicate the number.
        Leader[ID] = 1; //This will remain as "1". This shows that the player ur setting is a leader.
        IsLaw[ID] = 0; // This shows that the org is not a law enforcement, its a Gang.
        format(str, 123, "You have set a player leader of Rudyy's Gang.");
        SendClientMessage(playerid,red, str);
    }
    return 1;

}
if(Leader[playerid] == 1) {
if (streq(cmd,"/setmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /setmember [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[11]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
     if(IsInOrg[ID] == 1) return SendClientMessage(playerid,red,"Ths user is already in an organization!");
     else   if(Member[playerid] == 1 && Member[ID] == 0)
{
        format(str, 123, "Your application to join Rudy's Gang has been accepted by leader %s.", pName);
SendClientMessage(ID,COLOR_LIGHTBLUE,str);
       SetPlayerColor(ID,0x0000BBAA); //color
        SendClientMessage(ID,green, str);
        GivePlayerWeapon(ID,24,250); //weapon1
        GivePlayerWeapon(ID,3,99999); //weapon2
        GivePlayerWeapon(ID,29,1000); //weapon3 (optional)
        IsInOrg[ID] = 1; //Shows that the user that leader is recruiting is is in org.
        IsLaw[ID] = 0; //Not a law, gang.
        Member[ID] = 1; // Org ID
        format(str, 123, "You have accepted the following member into your organization.");
        SendClientMessage(playerid,COLOR_LIGHTBLUE, str);
}
return 1;
}
}
}

     else if (streq(cmd,"/kickmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /kickmember [playerid]");
        return 1;
    }

    new ID = strval(cmdtext[11]);
    new pName[24], str[64];

    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
 if(Member[playerid] == 1 && Member[ID] == 1)
{
        format(str, 123, "Leader %s has kicked you from organization Rudy's gang.", pName);
        SendClientMessage(ID,COLOR_ORANGE, str);
        SetPlayerSkin(ID, 299);
        ResetPlayerWeapons(ID);
        Member[ID] = 0;
        IsLaw[playerid] = 0;
        IsInOrg[ID] = 0;
        SetPlayerColor(ID, 0xFFFFFFFF);
        format(str, 123, "You have kicked a player from Rudy's gang.");
        SendClientMessage(playerid,red, str);

}
return 1;
}
}

Add this on OnPlayerDisconnect, So it will save the user data when he disconnect from your server

pawn Код:
new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s_ORG.ini, name);
dini_IntSet(file,"
Leader",Leader[playerid]);
dini_IntSet(file,"
InOrg",IsInOrg[playerid]);
dini_IntSet(file,"
Law",IsLaw[playerid]);
And on OnPlayerConnect, so it will restore all your data.

pawn Код:
new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s_ORG.ini, name);
                    Member[playerid] = dini_Int(file, "
Member");
                    Leader[playerid] = dini_Int(file,"
Leader");
                    IsInOrg[playerid] = dini_Int(file,"
InOrg");
                    IsLaw[playerid] = dini_Int(file,"
Law");

and dont forget to add this at bottom of your script
pawn Код:
streq(str1[],str2[])
{
        if (strlen(str1)!=strlen(str2)) return 0;

        return strcmp(str1,str2,true)==0;
}
Thanks for reading my tutorial.

Any error? Reply below.

It will look like this
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <dudb>
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define yellow 0xFFFF00AA
#define COLOR_POWDERBLUE 0xB0E0E6FF
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GOLD 0xFFD700FF
#define COLOR_LIGHTGREEN 0x90EE90FF
#define COLOR_OLIVE 0x808000FF
#define COLOR_ORED 0xFF0000FF
#define COLOR_SALMON 0xFA8072FF
#define COLOR_GREEN 0x00F20096
#define green 0x00F20096
#define red 0xFF0000FF
#define RED 0xFF0000FF
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_TEAL 0x008080FF
#define COLOR_BROWN 0xFFBB7796
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}
new Member[MAX_PLAYERS];
new Leader[MAX_PLAYERS];
new IsInOrg[MAX_PLAYERS];
new IsLaw[MAX_PLAYERS];
public OnFilterScriptExit()
{
    return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s_ORG.ini", name);
                    Member[playerid] = dini_Int(file, "Member");
                    Leader[playerid] = dini_Int(file,"Leader");
                    IsInOrg[playerid] = dini_Int(file,"InOrg");
                    IsLaw[playerid] = dini_Int(file,"Law");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s_ORG.ini", name);
dini_IntSet(file,"Leader",Leader[playerid]);
dini_IntSet(file,"InOrg",IsInOrg[playerid]);
dini_IntSet(file,"Law",IsLaw[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
 new cmd[256];
 new idx;
 cmd = strtok(cmdtext, idx);

    if (streq(cmd,"/setleader1"))
{
    if(!strlen(cmdtext[12]))
    {
        SendClientMessage(playerid, red, "Usage: /setleader1 [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[12]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
        format(str, 123, "Admin %s has set your the leader of organization Rudyy's Gang.", pName);
        SendClientMessage(ID,COLOR_LIGHTBLUE, str);
        SetPlayerColor(ID, 0x00C300FF); // Color
        GivePlayerWeapon(ID,28,5000); // Weapon1
        GivePlayerWeapon(ID,1,-1); // Weapon 2
        IsInOrg[ID] = 1; // This tells that the user is already in an organization.
        Member[ID] = 1; //This is org id, forexample my org id i want is 1 , so i will put 1, if i want it 2 , i will put 2. Note; do not duplicate the number.
        Leader[ID] = 1; //This will remain as "1". This shows that the player ur setting is a leader.
        IsLaw[ID] = 0; // This shows that the org is not a law enforcement, its a Gang.
        format(str, 123, "You have set a player leader of Rudyy's Gang.");
        SendClientMessage(playerid,red, str);
    }
    return 1;

}
if(Leader[playerid] == 1) {
if (streq(cmd,"/setmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /setmember [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[11]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
     if(IsInOrg[ID] == 1) return SendClientMessage(playerid,red,"Ths user is already in an organization!");
     else   if(Member[playerid] == 1 && Member[ID] == 0)
{
        format(str, 123, "Your application to join Rudy's Gang has been accepted by leader %s.", pName);
SendClientMessage(ID,COLOR_LIGHTBLUE,str);
       SetPlayerColor(ID,0x0000BBAA); //color
        SendClientMessage(ID,green, str);
        GivePlayerWeapon(ID,24,250); //weapon1
        GivePlayerWeapon(ID,3,99999); //weapon2
        GivePlayerWeapon(ID,29,1000); //weapon3 (optional)
        IsInOrg[ID] = 1; //Shows that the user that leader is recruiting is is in org.
        IsLaw[ID] = 0; //Not a law, gang.
        Member[ID] = 1; // Org ID
        format(str, 123, "You have accepted the following member into your organization.");
        SendClientMessage(playerid,COLOR_LIGHTBLUE, str);
}
return 1;
}
}
}

     else if (streq(cmd,"/kickmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /kickmember [playerid]");
        return 1;
    }

    new ID = strval(cmdtext[11]);
    new pName[24], str[64];

    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
 if(Member[playerid] == 1 && Member[ID] == 1)
{
        format(str, 123, "Leader %s has kicked you from organization Rudy's gang.", pName);
        SendClientMessage(ID,COLOR_ORANGE, str);
        SetPlayerSkin(ID, 299);
        ResetPlayerWeapons(ID);
        Member[ID] = 0;
        IsLaw[playerid] = 0;
        IsInOrg[ID] = 0;
        SetPlayerColor(ID, 0xFFFFFFFF);
        format(str, 123, "You have kicked a player from Rudy's gang.");
        SendClientMessage(playerid,red, str);

}
return 1;
}
}
    return 0;
}

streq(str1[],str2[])
{
        if (strlen(str1)!=strlen(str2)) return 0;

        return strcmp(str1,str2,true)==0;
}
Reply
#2

Thanks alot man i am going to try this now!

I tried it and its cool,but i know tis basic org script i would still like to make some suggestions.

Suggestions:

/lc - Law chat.
/oc - For gangs and private buss.
Make it possbible to add cars for the faction,and only the members can enter.
/oskin and /lskin for leader and member skin please. 3 skin for members and 1 skin for leader.
10 cars per org.

If you can make it it would be pro org script
Reply
#3

Thanks Jacks
Reply
#4

someone help me with this Error:

C:\Users\ALI\Desktop\sa-mpserver\sa-mpserver\gamemodes\Ali'sOrgs.pwn(6 : warning 217: loose indentation
C:\Users\ALI\Desktop\sa-mpserver\sa-mpserver\gamemodes\Ali'sOrgs.pwn(69) : error 037: invalid string (possibly non-terminated string)
C:\Users\ALI\Desktop\sa-mpserver\sa-mpserver\gamemodes\Ali'sOrgs.pwn(69) : error 029: invalid expression, assumed zero
C:\Users\ALI\Desktop\sa-mpserver\sa-mpserver\gamemodes\Ali'sOrgs.pwn(69) : error 017: undefined symbol "ini"
C:\Users\ALI\Desktop\sa-mpserver\sa-mpserver\gamemodes\Ali'sOrgs.pwn(69) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#5

Show me the error lines
Reply
#6

Dumb ass u forgot request want me to add?
Reply
#7

No offence, but you should be careful with the arrays. Because 256 is pretty memory wasting

pawn Код:
new file[_256_];
format(file, sizeof(file), "%s_ORG.ini", name);
A name is max. 24, _ORG.ini = 8, (24 + 8 = 32), 32 is needed. So I recommend it to set it to 40
And the other thing
pawn Код:
new cmd[_256_];
while the max command is < 20 in the script, I bet you don't need a command like:
pawn Код:
/3u2846273487385743859347r8hdsfyr8yfhew879hy3ryw8eyfew8uvb9uqr9423u09rue0[vcnutq34nuq434u38jerf8q43jtqug8h5w8rjf8qhg879hw54etrf8hw5t8ghjw95hgw8y5h9wer9fypw834fh3w94ht9whgfhq347tyew9rhp3u2846273487385743859347r8hdsfyr8yfhew879hy3ryw8eyfew8uvb9uqr9423u09rue0
That are 256 letters ^^

But the rest is good, well done
Reply
#8

Please Help guys /kickmember command isnt working heres The FS down



Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <dudb>
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define yellow 0xFFFF00AA
#define COLOR_POWDERBLUE 0xB0E0E6FF
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GOLD 0xFFD700FF
#define COLOR_LIGHTGREEN 0x90EE90FF
#define COLOR_OLIVE 0x808000FF
#define COLOR_ORED 0xFF0000FF
#define COLOR_SALMON 0xFA8072FF
#define COLOR_GREEN 0x00F20096
#define green 0x00F20096
#define red 0xFF0000FF
#define RED 0xFF0000FF
#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_TEAL 0x008080FF
#define COLOR_BROWN 0xFFBB7796
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}
new Member[MAX_PLAYERS];
new Leader[MAX_PLAYERS];
new IsInOrg[MAX_PLAYERS];
new IsLaw[MAX_PLAYERS];
public OnFilterScriptExit()
{
    return 1;
}
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s_ORG.ini", name);
Member[playerid] = dini_Int(file, "Member");
Leader[playerid] = dini_Int(file,"Leader");
IsInOrg[playerid] = dini_Int(file,"InOrg");
IsLaw[playerid] = dini_Int(file,"Law");
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s_ORG.ini", name);
dini_IntSet(file,"Leader",Leader[playerid]);
dini_IntSet(file,"InOrg",IsInOrg[playerid]);
dini_IntSet(file,"Law",IsLaw[playerid]);
return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
 new cmd[256];
 new idx;
 cmd = strtok(cmdtext, idx);

if (streq(cmd,"/setleader1"))
{
    if(!strlen(cmdtext[12]))
    {
        SendClientMessage(playerid, red, "Usage: /setleader1 [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[12]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
        format(str, 123, "Admin %s has set your the leader of organization Rudyy's Gang.", pName);
        SendClientMessage(ID,COLOR_LIGHTBLUE, str);
        SetPlayerColor(ID, 0x00C300FF); // Color
        GivePlayerWeapon(ID,28,5000); // Weapon1
        GivePlayerWeapon(ID,1,-1); // Weapon 2
        IsInOrg[ID] = 1; // This tells that the user is already in an organization.
        Member[ID] = 1; //This is org id, forexample my org id i want is 1 , so i will put 1, if i want it 2 , i will put 2. Note; do not duplicate the number.
        Leader[ID] = 1; //This will remain as "1". This shows that the player ur setting is a leader.
        IsLaw[ID] = 0; // This shows that the org is not a law enforcement, its a Gang.
        format(str, 123, "You have set a player leader of Rudyy's Gang.");
        SendClientMessage(playerid,red, str);
    }
    return 1;

}
if(Leader[playerid] == 1) {
if (streq(cmd,"/setmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /setmember [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[11]);
    new pName[24], str[64];
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
     if(IsInOrg[ID] == 1) return SendClientMessage(playerid,red,"Ths user is already in an organization!");
     else   if(Member[playerid] == 1 && Member[ID] == 0)
{
        format(str, 123, "Your application to join Rudy's Gang has been accepted by leader %s.", pName);
SendClientMessage(ID,COLOR_LIGHTBLUE,str);
       SetPlayerColor(ID,0x0000BBAA); //color
        SendClientMessage(ID,green, str);
        GivePlayerWeapon(ID,24,250); //weapon1
        GivePlayerWeapon(ID,3,99999); //weapon2
        GivePlayerWeapon(ID,29,1000); //weapon3 (optional)
        IsInOrg[ID] = 1; //Shows that the user that leader is recruiting is is in org.
        IsLaw[ID] = 0; //Not a law, gang.
        Member[ID] = 1; // Org ID
        format(str, 123, "You have accepted the following member into your organization.");
        SendClientMessage(playerid,COLOR_LIGHTBLUE, str);
}
return 1;
}
}
}

     else if (streq(cmd,"/kickmember"))
{
    if(!strlen(cmdtext[11]))
    {
        SendClientMessage(playerid, red, "Usage: /kickmember [playerid]");
        return 1;
    }

    new ID = strval(cmdtext[11]);
    new pName[24], str[64];

    if(IsPlayerConnected(ID))
    {
        GetPlayerName(playerid, pName, 24);
 if(Member[playerid] == 1 && Member[ID] == 1)
{
        format(str, 123, "Leader %s has kicked you from organization Rudy's gang.", pName);
        SendClientMessage(ID,COLOR_ORANGE, str);
        SetPlayerSkin(ID, 299);
        ResetPlayerWeapons(ID);
        Member[ID] = 0;
        IsLaw[playerid] = 0;
        IsInOrg[ID] = 0;
        SetPlayerColor(ID, 0xFFFFFFFF);
        format(str, 123, "You have kicked a player from Rudy's gang.");
        SendClientMessage(playerid,red, str);

}
return 1;
}
}
    return 0;
}

streq(str1[],str2[])
{
        if (strlen(str1)!=strlen(str2)) return 0;

        return strcmp(str1,str2,true)==0;
}
Reply
#9

Quote:
Originally Posted by Huzzy
Посмотреть сообщение
Thanks alot man i am going to try this now!

I tried it and its cool,but i know tis basic org script i would still like to make some suggestions.

Suggestions:

/lc - Law chat.
/oc - For gangs and private buss.
Make it possbible to add cars for the faction,and only the members can enter.
/oskin and /lskin for leader and member skin please. 3 skin for members and 1 skin for leader.
10 cars per org.

If you can make it it would be pro org script
Yeahh.. i recommended add thoses things & fix the /kickmember please..

Regards..
Mr.Jvxmc
Reply
#10

If the Warning ret_memcpy comes to u, to fix it put this:

#pragma unused ret_memcpy

on the top of your script
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)