Help /facpay wount work!
#1

Hello! When i use /facpay to set faction rank payment it only lets to set 2 ranks and even those two ranks wount work! Could you please help me i cant figure out whats the problem.

Here's the command:


Код:
CMD:facpay(playerid, params[])
{
	new rank, amount, string[128];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
	if(!PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playerid, COLOR_GREY, "You are not a faction leader.");
	if(sscanf(params, "ui", rank, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /facpay (Currently not working)");
	if(amount > 300000) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Amount");
	if(amount <= 0) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Amount");
    new idx = PlayerInfo[playerid][pFac];
	if(PlayerInfo[playerid][pFacLeader])
	switch(rank)
	{
	    case 0:
	    {
	    	FacInfo[idx][fPay1] = amount;
	        format(string, sizeof(string), "You have set rank 1's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 1:
	    {
	        FacInfo[idx][fPay2] = amount;
	        format(string, sizeof(string), "You have set rank 2's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 2:
	    {
	        FacInfo[idx][fPay3] = amount;
	        format(string, sizeof(string), "You have set rank 3's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 3:
	    {
	        FacInfo[idx][fPay4] = amount;
	        format(string, sizeof(string), "You have set rank 4's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
     	case 4:
	    {
	        FacInfo[idx][fPay5] = amount;
	        format(string, sizeof(string), "You have set rank 5's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 5:
	    {
	        FacInfo[idx][fPay6] = amount;
	        format(string, sizeof(string), "You have set rank 6's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 6:
	    {
	        FacInfo[idx][fPay7] = amount;
	        format(string, sizeof(string), "You have set rank 7's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 7:
	    {
	        FacInfo[idx][fPay8] = amount;
	        format(string, sizeof(string), "You have set rank 8's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 8:
	    {
	        FacInfo[idx][fPay9] = amount;
	        format(string, sizeof(string), "You have set rank 9's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 9:
	    {
	        FacInfo[idx][fPay10] = amount;
	        format(string, sizeof(string), "You have set rank 10's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	    case 10:
	    {
	        FacInfo[idx][fPay11] = amount;
	        format(string, sizeof(string), "You have set rank 11's pay to %d", amount);
	        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	    }
	}
	return 1;
}
Heres anotherone
Код:
stock FACPAY(playerid)
{
	new pay[10];
	if(PlayerInfo[playerid][pFacRank] == 0 && PlayerInfo[playerid][pFac] == 0) format(pay, sizeof(pay), "None");
	else if(PlayerInfo[playerid][pFac])
	{
		if(PlayerInfo[playerid][pFacRank] == 0) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay1]);
		else if(PlayerInfo[playerid][pFacRank] == 1) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay2]);
		else if(PlayerInfo[playerid][pFacRank] == 2) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay3]);
		else if(PlayerInfo[playerid][pFacRank] == 3) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay4]);
		else if(PlayerInfo[playerid][pFacRank] == 4) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay5]);
		else if(PlayerInfo[playerid][pFacRank] == 5) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay6]);
		else if(PlayerInfo[playerid][pFacRank] == 6) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay7]);
		else if(PlayerInfo[playerid][pFacRank] == 7) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay8]);
		else if(PlayerInfo[playerid][pFacRank] == 8) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay9]);
		else if(PlayerInfo[playerid][pFacRank] == 9) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay10]);
		else if(PlayerInfo[playerid][pFacRank] == 10) format(pay, sizeof(pay), "%d", FacInfo[PlayerInfo[playerid][pFac]][fPay11]);
	}
	return pay;
}
And here's dini:
Код:
stock SaveFactions()
{
	// LSPD
	new file[64];
	format(file, sizeof(file), "factions/LSPD.ini");
	if(!dini_Exists(file)) dini_Create(file);
	dini_Set(file, "LSPDMembers", FacInfo[1][facMembers]);
	dini_Set(file, "Rank1", FacInfo[1][fRank1]);
	dini_Set(file, "Rank2", FacInfo[1][fRank2]);
	dini_Set(file, "Rank3", FacInfo[1][fRank3]);
	dini_Set(file, "Rank4", FacInfo[1][fRank4]);
	dini_Set(file, "Rank5", FacInfo[1][fRank5]);
	dini_Set(file, "Rank6", FacInfo[1][fRank6]);
	dini_Set(file, "Rank7", FacInfo[1][fRank7]);
	dini_Set(file, "Rank8", FacInfo[1][fRank8]);
	dini_Set(file, "Rank9", FacInfo[1][fRank9]);
	dini_Set(file, "Rank10", FacInfo[1][fRank10]);
	dini_Set(file, "Rank10", FacInfo[1][fRank11]);
	dini_Set(file, "Div1", FacInfo[1][fDiv1]);
	dini_Set(file, "Div2", FacInfo[1][fDiv2]);
	dini_Set(file, "Div3", FacInfo[1][fDiv3]);
	dini_Set(file, "Div4", FacInfo[1][fDiv4]);
	dini_Set(file, "Div5", FacInfo[1][fDiv5]);
	format(file, sizeof(file), "factions/LSPD.ini");
	dini_Set(file, "Pay1", FacInfo[1][fPay1]);
	dini_Set(file, "Pay2", FacInfo[1][fPay2]);
	dini_Set(file, "Pay3", FacInfo[1][fPay3]);
	dini_Set(file, "Pay4", FacInfo[1][fPay4]);
	dini_Set(file, "Pay5", FacInfo[1][fPay5]);
	dini_Set(file, "Pay6", FacInfo[1][fPay6]);
	dini_Set(file, "Pay7", FacInfo[1][fPay7]);
	dini_Set(file, "Pay8", FacInfo[1][fPay8]);
	dini_Set(file, "Pay9", FacInfo[1][fPay9]);
	dini_Set(file, "Pay10", FacInfo[1][fPay10]);
	dini_Set(file, "Pay11", FacInfo[1][fPay11]);
	print("BCSD files saved successfully.");
Reply
#2

I see no major problem, so no clue but some minor problems
PHP код:
CMD:facpay(playeridparams[])
{
    
// ...
    // you can combine the amount checks
    
if(amount 300000 || amount <= 0) return // ...
    // missing rank check
    
if(!(<= rank <= 10)) return // ...
    // use arrays inside enums "fPay[10]"
    
new idx PlayerInfo[playerid][pFac];
    
FacInfo[idx][fPay][rank] = amount;
    
format(stringsizeof(string), "You have set rank %d's pay to %d"rank 1amount);
    
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
    return 
1;

PHP код:
stock FACPAY(playerid)
{
    new 
pay[10];
    new 
faction PlayerInfo[playerid][pFac];
    if(
faction) { // rank as array like above
        
strcat(payFacInfo[faction][fPay][ PlayerInfo[playerid][pFacRank] ]);
    } else {
        
pay "None";
    }
    return 
pay;

Same with SaveFactions, change your variables to arrays
Reply
#3

So in save in need to change the "fpay1" to "fpay[1]" ?
Reply
#4

Quote:
Originally Posted by priit123
Посмотреть сообщение
So in save in need to change the "fpay1" to "fpay[1]" ?
PHP код:
// array starts at 0 instead of 1, so it is 0-10 instead of 1-11
dini_Set(file"Pay1"FacInfo[1][fPay][0]);
dini_Set(file"Pay2"FacInfo[1][fPay][1]);
dini_Set(file"Pay3"FacInfo[1][fPay][2]);
// ...
dini_Set(file"Pay9"FacInfo[1][fPay][8]);
dini_Set(file"Pay10"FacInfo[1][fPay][9]);
dini_Set(file"Pay11"FacInfo[1][fPay][10]); 
But you could also use an loop
PHP код:
for(new 0key[16]  = "Pay"<= 10; ++i) {
    
valstr(key[3], 1); // faster than format
    
dini_Set(filekeyFacInfo[1][fPay][i]); // dini is quite old and slow
    // if you feel that your SaveFactions takes to long try to update to a newer filesystem or use a database

just noticed you got
PHP код:
format(filesizeof(file), "factions/LSPD.ini"); 
twice in your code
Reply
#5

enums will look like this am i right?:
Код:
fPay[1],
	fPay[2],
	fPay[3],
	fPay[4],
	fPay[5],
	fPay[6],
	fPay[7],
	fPay[8],
	fPay[9],
	fPay[10],
	fPay[11]
Reply
#6

no just once, like 1d arrays
PHP код:
fPay[11], 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)