SA-MP Forums Archive
Little problem. - 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: Little problem. (/showthread.php?tid=272195)



Little problem. - budelis - 27.07.2011

Hi all again.I do car market,and problem is player can buy,just first car here is a script:

pawn Код:
if(dialogid == 5227)
    {
    if(response)
    {
    if(PlayerData[playerid][pcar] != -1 && PlayerData[playerid][pcar2] != -1)
    {
    SendClientMessage(playerid,-1,"Only 2 cars");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(model == 534)//REMINGTON
    {
    if(GetPlayerMoneyA(playerid) < 9000)
    {
    SendClientMessage(playerid,  COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=2");
    return 1;
    }
    if(model == 533)//FELTZER
    {
    if(GetPlayerMoneyA(playerid) < 7000)
    {
    SendClientMessage(playerid, COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=2");
    return 1;
    }
This is just part,but in this when i press (response) it only work on remington,when i go to feltzer(and others market cars) nothing happines,where is problem?maybe to mach return or some thing ...


Re: Little problem. - Davz*|*Criss - 27.07.2011

I don't understand what are you talking abot.

Explain better please, I don't know what you mean.


Re: Little problem. - budelis - 27.07.2011

When player enter to car who is in market player get's dialog with id 5227,and how you see i check model,money,but this work,just for first checking car model now is REMINGTON.

Код:
if(model == 534)//REMINGTON
    {
    if(GetPlayerMoneyA(playerid) < 9000)
    {
    SendClientMessage(playerid,  COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=2");
    return 1;
    }
This code is work,but when i add more:

Код:
if(model == 534)//REMINGTON
    {
    if(GetPlayerMoneyA(playerid) < 9000)
    {
    SendClientMessage(playerid,  COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=2");
    return 1;
    }
    if(model == 533)//FELTZER
    {
    if(GetPlayerMoneyA(playerid) < 7000)
    {
    SendClientMessage(playerid, COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=2");
    return 1;
    }
And how you see i do another if(model and now is don't work,player don't get message "You but FELTZER=2 or =1,but it for all cars model what i add,maybe it's need use else or anything thing


Re: Little problem. - budelis - 27.07.2011

Help any if can.


Re: Little problem. - budelis - 27.07.2011

Sorry for double post,but i very need help with this.And i wanna to say i think this is problem with return i think or else ,because i try remove returns and work for 1 vehicle,but others vehicle don't work...


Re: Little problem. - Pasa - 27.07.2011

try this, I'm not sure will this work
PHP код:
if(dialogid == 5227)
    {
        if(
response)
        {
            if(
PlayerData[playerid][pcar] != -&& PlayerData[playerid][pcar2] != -1)
                {
                    
SendClientMessage(playerid,-1,"Only 2 cars");
                    
SetVehicleToRespawn(vehicleid);
                    return 
1;
                }
                if(
model == 534)//REMINGTON
                
{
                    if(
GetPlayerMoneyA(playerid) < 9000)
                    {
                        
SendClientMessage(playerid,  COLOR_RED"Enought money");
                        
SetVehicleToRespawn(vehicleid);
                        return 
1;
                    }
                    if(
PlayerData[playerid][pcar] == -1)
                    {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy REMINGTON=1");
                    }
                else
                    {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy REMINGTON=2");
                    }
                return 
1;
            }
            if(
model == 533)//FELTZER
                
{
                    if(
GetPlayerMoneyA(playerid) < 7000)
                    {
                        
SendClientMessage(playeridCOLOR_RED"Enought money");
                        
SetVehicleToRespawn(vehicleid);
                        return 
1;
                    }
                    if(
PlayerData[playerid][pcar] == -1)
                    {
                    
SendClientMessage(playeridCOLOR_GREEN"You buy FELTZER=1");
                    }
                    else
                   {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy FELTZER=2");
                    }
                return 
1;
            } 



Re: Little problem. - AndreT - 27.07.2011

One small thing that bothers me, what's the model variable actually for or how is it assigned?

Also, a small thing to make your code better would be using a switch statement there.
pawn Код:
switch(model)
{
    case 534:
    {
    }
    case 533:
    {
    }
    //...
}
Something to make your code better structured (for some eyes that is):
pawn Код:
// instead of this:
if(response)
{
    switch(model)
    {
        // ...
    }
}

// act like this:
if(!response)
    return true;

switch(model)
{
    // ...
}
There's some useless returning as well...
pawn Код:
if(PlayerData[playerid][pcar] == -1)
{
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=1");
}
else
{
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=2");
    return 1; // <-- useless return,
}
return 1; // <-- this one will do the job



Re: Little problem. - budelis - 29.07.2011

AndreT i don't understand you.I try to do with switch but i do wrong,maybe you can to that with that script who i give:

Код:
if(model == 534)//REMINGTON
    {
    if(GetPlayerMoneyA(playerid) < 9000)
    {
    SendClientMessage(playerid,  COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy REMINGTON=2");
    return 1;
    }
    if(model == 533)//FELTZER
    {
    if(GetPlayerMoneyA(playerid) < 7000)
    {
    SendClientMessage(playerid, COLOR_RED, "Enought money");
    SetVehicleToRespawn(vehicleid);
    return 1;
    }
    if(PlayerData[playerid][pcar] == -1)
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=1");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GREEN, "You buy FELTZER=2");
    return 1;
    }



Re: Little problem. - budelis - 29.07.2011

Quote:
Originally Posted by Pasa
Посмотреть сообщение
try this, I'm not sure will this work
PHP код:
if(dialogid == 5227)
    {
        if(
response)
        {
            if(
PlayerData[playerid][pcar] != -&& PlayerData[playerid][pcar2] != -1)
                {
                    
SendClientMessage(playerid,-1,"Only 2 cars");
                    
SetVehicleToRespawn(vehicleid);
                    return 
1;
                }
                if(
model == 534)//REMINGTON
                
{
                    if(
GetPlayerMoneyA(playerid) < 9000)
                    {
                        
SendClientMessage(playerid,  COLOR_RED"Enought money");
                        
SetVehicleToRespawn(vehicleid);
                        return 
1;
                    }
                    if(
PlayerData[playerid][pcar] == -1)
                    {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy REMINGTON=1");
                    }
                else
                    {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy REMINGTON=2");
                    }
                return 
1;
            }
            if(
model == 533)//FELTZER
                
{
                    if(
GetPlayerMoneyA(playerid) < 7000)
                    {
                        
SendClientMessage(playeridCOLOR_RED"Enought money");
                        
SetVehicleToRespawn(vehicleid);
                        return 
1;
                    }
                    if(
PlayerData[playerid][pcar] == -1)
                    {
                    
SendClientMessage(playeridCOLOR_GREEN"You buy FELTZER=1");
                    }
                    else
                   {
                        
SendClientMessage(playeridCOLOR_GREEN"You buy FELTZER=2");
                    }
                return 
1;
            } 
Don't work.


Re: Little problem. - Guest3598475934857938411 - 29.07.2011

Stop double posting, also I don't quite understand your question you said it works then what do you need?

Код:
and problem is player can buy,
If you claim it is working why is there a problem :O