SA-MP Forums Archive
2 bugs, help! - 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)
+--- Thread: 2 bugs, help! (/showthread.php?tid=383570)



2 bugs, help! - RLGaming - 07.10.2012

I have 2 bugs here..
+rep to anyone who can help!

1st bug:
Whenever I set myself to a different faction type, I.E. faction type 2 it always shows faction type 1 CMD's
code:
Quote:

if(arrFaction[playerid][p_iMember] > -1 && arrFaction[playerid][g_iFactionType] == 1)
{
SendClientMessage(playerid, COLOR_BLUE, "*** LAW ENFORCEMENT *** /breathalizer - /fingerprint - /m[egaphone] - /su - /arrest - /tow - /untow");
SendClientMessage(playerid, COLOR_BLUE, "*** LAW ENFORCEMENT *** /searchtruck - /cleartruck - /cuff - /uncuff - givedl - /revokedl - /mdc - /gov");
}
if(arrFaction[playerid][p_iMember] > -1 && arrFaction[playerid][g_iFactionType] == 2)
{
SendClientMessage(playerid, COLOR_GREY, "*** GOVERNMENT *** /mdc ");
}

I snipped it out of my /help since it was a big code, but whenever I set myself to fac type 2 through my .ini file, cmd's, etc it doesnt show the government it still shows law enforcement

2nd bug:
whenever I do /gov it always says 'undefined'

Code:
Quote:

FactionRanks_ReturnType(iFac) {

new
szName[32] = "Undefined";

switch(arrFaction[iFac][p_iRanks]) {
case 1: szName = "Cadet";
case 2: szName = "Officer";
case 3: szName = "Senior Officer";
case 4: szName = "Corporal";
case 5: szName = "Head Corporal";
case 6: szName = "Sergeant";
case 7: szName = "Senior Sergeant";
case 8: szName = "Lieutentant";
case 9: szName = "Captain";
case 10: szName = "Head Captain";
case 11: szName = "Assistant Chief";
case 12: szName = "Chief";
}
return szName;
}

Quote:

if(arrFaction[playerid][p_iMember] > 11 && arrFaction[playerid][g_iFactionType] == 1)
{
if(arrFaction[playerid][p_iMember] == 12)
{
format(string, sizeof(string), "** %s %s: %s **", FactionRanks_ReturnType(playerid), GetPlayerNameEx(playerid), params);
SendClientMessageToAll(COLOR_WHITE, "|___________ Government News Announcement ___________|");
SendClientMessageToAll(COLOR_DBLUE, string);
}
else if(arrFaction[playerid][p_iMember] == 11)
{
format(string, sizeof(string), "** %s %s: %s **", FactionRanks_ReturnType(playerid), GetPlayerNameEx(playerid), params);
SendClientMessageToAll(COLOR_WHITE, "|___________ Government News Announcement ___________|");
SendClientMessageToAll(COLOR_DBLUE, string);
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "You are not a high enough rank to use this!");
}
}

some of my /gov cmd where the ranks are a post to appear


Re: 2 bugs, help! - Riddick94 - 07.10.2012

What about your Member state? You got a separate member for every faction?

2nd bug:
Use a function strset.

pawn Код:
stock strset(dest[], source[])
{
    new count = strlen(source);
    for(new i = 0; i < count; i++)
    {
        dest[i] = source[i];
    }
    dest[count] = 0;
}



Re: 2 bugs, help! - RLGaming - 07.10.2012

Yes I do

and I have no idea how to use that lol


Re: 2 bugs, help! - Riddick94 - 07.10.2012

Remove from the both 'if' statements this:

pawn Код:
arrFaction[playerid][p_iMember] > -1 &&
and then check the code.

About your second problem how to use it.. You don't need "szName" array. Just remove that and do this like that:

pawn Код:
case 1: strset(PlayerFactionNameArray, "Cadet");
[...]



Re: 2 bugs, help! - RLGaming - 07.10.2012

the /help still only shows law enforcement ;/


Re: 2 bugs, help! - Riddick94 - 07.10.2012

It can't be..

pawn Код:
switch(arrFaction[playerid][g_iFactionType])
{
case 1:/*Law message*/
case 2:/*Gov. message*/
default:// Error message
}
It must work, otherwise, there's a problem in set to your enum array.


Re: 2 bugs, help! - RLGaming - 07.10.2012

Your right sorry! Got my /makeleader messed up, fixed now! thank you

Also on my /stats

I am trying to show the faction name they are in
I have this:
Quote:

new factioninformation[20];
if(arrFaction[playerid][p_iMember] == -1)
{ factioninformation = "None"; }
else if(arrFaction[playerid][p_iMember] > 0)
{ factioninformation = arrFaction[playerid][g_szFactionName]; }

But it returns an error:
Quote:

array sizes do not match, or destination array is too small

on this line:
Quote:

{ factioninformation = arrFaction[playerid][g_szFactionName]; }

I dunno how I can get it to do the faction name on the stats if the code above doesnt work ;/


Re: 2 bugs, help! - PrawkC - 07.10.2012

you could use either strcat, or format.. ie

format(factioninformation, sizeof(factioninformation), "%s", arrFaction[][]);

not advised to use format though.


Re: 2 bugs, help! - RLGaming - 08.10.2012

no idea what you mean lol

bump


Re: 2 bugs, help! - Riddick94 - 08.10.2012

pawn Код:
new factioninformation[20];
Increase this array to 32, and show your declaring in enum of the g_szFactionName array.