SA-MP Forums Archive
Premium Account - 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: Premium Account (/showthread.php?tid=577075)



Premium Account - Sn4ke2 - 08.06.2015

hello guys, i want to make dialog to can players buy premium account but i faild
I take from command /setpremium and put on dialog but i take errors " warning 217: loose indentation"
this is the command:
PHP код:
CMD:setpremium(playerid,params[])
{
    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"Trebuie sa te loghezi mai intai.");
    if (
PlayerInfo[playerid][pAdmin] < 5) return SCM(playerid,COLOR_WHITE,AdminOnly);
    new 
id,sendername[25],string[128];
    if(
sscanf(params"u",id)) return SCM(playeridCOLOR_WHITE"{B8DBFF}USE: /setpremium <Name/Playerid>");
    if(
PlayerInfo[id][pPremiumAccount] == 1) return SCM(playerid,COLOR_LIGHTRED"Error:{FFFFFF} Acest player detine cont premium.");
    
PlayerInfo[id][pPremiumAccount] = 1;
    
GetPlayerName(playeridsendernamesizeof(sendername));
    
format(stringsizeof(string), "Admin %s a setat cont-ul dvs. Premium.",sendername);
    
SCM(playerid,COLOR_LIGHTRED,string);
    
GetPlayerName(id,sendername,sizeof(sendername));
    
format(stringsizeof(string), "UPDATE users SET `Premium`='1' WHERE `name`='%s'",sendername);
    
mysql_query(SQL,string);
    return 
1;

and this is dialog
PHP код:
if(response)
        {
            if(
listitem == 0)
            {
                if(
PlayerInfo[playerid][pHPoints] <1500) return SCM(playerid,-1,"{37B9C8}You don't have 1500 PremiumPoints.");//premium
                
PlayerInfo[playerid][pHPoints] -= 1500;
                
//GivePlayerCash(playerid,15000);
                //Update(playerid,pCashx);
                //Update(playerid,pHPointsx);
                
new id,sendername[25],string[128];
                if(
PlayerInfo[id][pPremiumAccount] == 1) return SCM(playerid,COLOR_LIGHTRED"Error:{FFFFFF}Ai cont preimum.");
                
PlayerInfo[id][pPremiumAccount] = 1;
                
GetPlayerName(id,sendername,sizeof(sendername));
                
format(stringsizeof(string), "UPDATE users SET `Premium`='1' WHERE `name`='%s'",sendername);
                
mysql_query(SQL,string);
                
SCM(playerid,-1,"{33CCFF}Felicitari ai cumparat cont premium.");
            } 



Re: Premium Account - DarkLored - 08.06.2015

That warning means that you need to organize your code, try organizing the dialog and it should work.


Re: Premium Account - Sn4ke2 - 08.06.2015

I organize and thank you, not warning "loose identation"
But i have too more warning's
PHP код:
 Gamelife.pwn(40141) : warning 219local variable "sendername" shadows a variable at a preceding level
Gamelife
.pwn(40141) : warning 219local variable "string" shadows a variable at a preceding level 
and the line

PHP код:
new id,sendername[26],string[129]; 



Re: Premium Account - DarkLored - 08.06.2015

Make sure you don't have them as global variables on top of your script.


Re: Premium Account - Sn4ke2 - 08.06.2015

well it's on command /setpremium.


Re: Premium Account - Sn4ke2 - 09.06.2015

any help's ?


Re: Premium Account - JaydenJason - 09.06.2015

Код:
CMD:setpremium(playerid,params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi mai intai.");
	if (PlayerInfo[playerid][pAdmin] < 5) return SCM(playerid,COLOR_WHITE,AdminOnly);
	new id,sendernamee[25],stringg[128];
	if(sscanf(params, "u",id)) return SCM(playerid, COLOR_WHITE, "{B8DBFF}USE: /setpremium <Name/Playerid>");
	if(PlayerInfo[id][pPremiumAccount] == 1) return SCM(playerid,COLOR_LIGHTRED, "Error:{FFFFFF} Acest player detine cont premium.");
	PlayerInfo[id][pPremiumAccount] = 1;
	GetPlayerName(playerid, sendernamee, sizeof(sendernamee));
	format(stringg, sizeof(stringg), "Admin %s a setat cont-ul dvs. Premium.",sendernamee);
	SCM(playerid,COLOR_LIGHTRED,stringg);
	GetPlayerName(id,sendernamee,sizeof(sendernamee));
	format(stringg, sizeof(stringg), "UPDATE users SET `Premium`='1' WHERE `name`='%s'",sendernamee);
	mysql_query(SQL,stringg);
	return 1;
}
//
if(response)
{
	if(listitem == 0)
	{
		if(PlayerInfo[playerid][pHPoints] <1500) return SCM(playerid,-1,"{37B9C8}You don't have 1500 PremiumPoints.");//premium
		PlayerInfo[playerid][pHPoints] -= 1500;
		//GivePlayerCash(playerid,15000);
		//Update(playerid,pCashx);
		//Update(playerid,pHPointsx);
		new id,sendernamee[25],string[128];
		if(PlayerInfo[id][pPremiumAccount] == 1) return SCM(playerid,COLOR_LIGHTRED, "Error:{FFFFFF}Ai cont preimum.");
		PlayerInfo[id][pPremiumAccount] = 1;
		GetPlayerName(id,sendernamee,sizeof(sendernamee));
		format(string, sizeof(string), "UPDATE users SET `Premium`='1' WHERE `name`='%s'",sendernamee);
		mysql_query(SQL,string);
		SCM(playerid,-1,"{33CCFF}Felicitari ai cumparat cont premium.");
	}



Re: Premium Account - mamorunl - 09.06.2015

The variables 'sendername' and 'string' are created inside your command and at the top of your script. You will need to remove one of the variables or rename them to get rid of the warning


Re: Premium Account - Sn4ke2 - 09.06.2015

Look how i make:
PHP код:
if(dialogid == DIALOG_HPoints1)
    {
        if(
response)
        {
            if(
listitem == 0)
            {
                new 
id,sendername[93],string[178];
                if(
PlayerInfo[playerid][pHPoints] <80) return SCM(playerid,-1,"{37B9C8}You don't have 80 gold.");
                
PlayerInfo[playerid][pHPoints] -= 80;
                if(
PlayerInfo[id][pPremiumAccount] == 1) return SCM(playerid,COLOR_LIGHTRED"Error:{FFFFFF} Acest player detine cont premium.");
                
PlayerInfo[id][pPremiumAccount] = 1;
                
GetPlayerName(id,sendername,sizeof(sendername));
                
format(stringsizeof(string), "UPDATE users SET `Premium`='1' WHERE `name`='%s'",sendername);
                
mysql_query(SQL,string);
            } 
now errors
PHP код:
Gamelife.pwn(40139) : warning 219local variable "sendername" shadows a variable at a preceding level
Gamelife
.pwn(40139) : warning 219local variable "string" shadows a variable at a preceding level 



Re: Premium Account - mamorunl - 09.06.2015

Код:
new id,sendername[93],string[178];
The last two variables are already created somewhere else in your script. Rename them or remove them depending on what the declarations are of the other two variables with the same name in another place in your script.