SA-MP Forums Archive
Dynamic Faction System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dynamic Faction System (/showthread.php?tid=243701)



Dynamic Faction System - Mike_Peterson - 24.03.2011

Hello all, it been a long time ago since i posted here.

I need some help with my scratch RP server together with my friend.
I wanted to make a command /makefaction and /deletefaction. But i've got a problem. Both of them don't work.
I am a good scripter but i haven't scripted PAWN for like 1-2 months so i dont know how to figure it out.
By typing /deletefaction and /makefaction it works correct. once im setting parameters it gives Unknown Command.
Please don't tell me to use zcmd.. im using dcmd.
heres the code.

pawn Code:
dcmd_makefaction(playerid,params[])
{
    new fname,fleader,fmoney,ftype,str[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[System] You need to be admin to use this command.");
    if(sscanf(params, "ssds", fname, fleader, fmoney, ftype)) return SendClientMessage(playerid, COLOR_RED, "[System]Usage: /makefaction [Faction Name] [Faction Leader] [Faction Money] [Faction Type]");
    format(str,sizeof(str),"You have made Faction: %s with the leader: %s and money: %s Type: %s",fname,fleader,fmoney, ftype);
    SendClientMessage(playerid,COLOR_BLUE,str);
    for(new i = 0; i < sizeof(FactionInfo); i++)
    {
        FactionInfo[i][FactionName] = fname;
        FactionInfo[i][FactionLeader] = fleader;
        FactionInfo[i][FactionMoney] = fmoney;
        FactionInfo[i][FactionType] = ftype;
        return 1;
    }
    return 1;
}

dcmd_deletefaction(playerid,params[])
{
    new fname,str[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[System] You need to be admin to use this command.");
    if(sscanf(params,"s",fname)) return SendClientMessage(playerid,COLOR_RED,"[System]Usage: /deletefaction [FactionName]");
    if(strfind(Ffile,FactionInfo[fname][FactionName],false) == -1) return SendClientMessage(playerid,COLOR_RED,"[System] Faction not found.");
    {
        for(new i = 0; i < sizeof(FactionInfo); i++)
        {
// First of all.. what do i need to type here. i got a Factions.ini in my scriptfiles folder
// But it'll have more factions.. I want to delete one entire faction.
            format(str,sizeof(str),"You have deleted the faction: %s",fname);
            SendClientMessage(playerid,COLOR_YELLOW,str);
            return 1;
        }
    }
    return 1;
}



Re: Dynamic Faction System - Mike_Peterson - 24.03.2011

EDIT:I managed to get makefaction working a bit but after one parameter it gives error unknown command.


Re: Dynamic Faction System - Biesmen - 24.03.2011

Quote:
Originally Posted by Mike_Peterson
View Post
I am a good scripter but i haven't scripted PAWN for like 1-2 months so i dont know how to figure it out.
Well, if you're a good scripter you wouldn't forget everything in 1-2 months .

Anyway, I don't really see anything that creates a faction at /makefaction, unless you got a function to save factions at OnGameModeExit.

Anyway, you didn't give your strings(fname, etc) a length.

Also, you have to use that length at your sscanf code.


Re: Dynamic Faction System - Mike_Peterson - 24.03.2011

Let's not call it good but experienced

Give a small example, (alstublieft?) Biesmen


Re: Dynamic Faction System - antonio112 - 24.03.2011

pawn Code:
dcmd_makefaction(playerid,params[])
{
    new fname[24],fleader[24],fmoney,ftype[24],str[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"[System] You need to be admin to use this command.");
    if(sscanf(params, "s[24]s[24]ds[24]", fname, fleader, fmoney, ftype)) return SendClientMessage(playerid, COLOR_RED, "[System]Usage: /makefaction [Faction Name] [Faction Leader] [Faction Money] [Faction Type]");
    format(str,sizeof(str),"You have made Faction: %s with the leader: %s and money: %s Type: %s",fname,fleader,fmoney, ftype);
    SendClientMessage(playerid,COLOR_BLUE,str);
    for(new i = 0; i < sizeof(FactionInfo); i++)
    {
        FactionInfo[i][FactionName] = fname;
        FactionInfo[i][FactionLeader] = fleader;
        FactionInfo[i][FactionMoney] = fmoney;
        FactionInfo[i][FactionType] = ftype;
        return 1;
    }
    return 1;
}
Something like that.


Re: Dynamic Faction System - Macluawn - 24.03.2011

There was a bit of a problem about looking for strings in the middle or at the start, since it doesnt know when the string should end.