SA-MP Forums Archive
Paintjob 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: Paintjob Help (/showthread.php?tid=407395)



Paintjob Help - kepa333 - 13.01.2013

Hello there i have problems with my script..... Its works for carkey1 and 2 but when i try cars with key 3,4,5 its not works its say "You are not in your vehicle". Plz help.

PHP код:
            else if(strcmp(x_nr,"paintjob",true) == 0)
            {
                if(
PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999 || PlayerInfo[playerid][pPcarkey4] == 9999 || PlayerInfo[playerid][pPcarkey5] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY,"   You don't have a vehicle to respray.");
                    return 
1;
                }
                if(!
IsAtDealership(playerid) && !IsAtPaySpray(playerid))
                {
                    
SendClientMessage(playeridCOLOR_GREY,"* You must be at a Dealership or a Pay'n'Spray to do this!");
                    return 
1;
                }
                if(
GetPlayerMoney(playerid) < 5000)
                {
                    
SendClientMessage(playeridCOLOR_GREY,"   You don't have enough money for vehicle respray.");
                    return 
1;
                }
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /v paintjob [paintjob(0-3)]");
                    return 
1;
                }
                new 
color1;
                
color1 strval(tmp);
                if(
color1 && color1 3)
                {
                    
SendClientMessage(playeridCOLOR_GREY"   Wrong Paintjob id!");
                    return 
1;
                }
                new 
vehid;
                if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey])
                {
                    
vehid PlayerInfo[playerid][pPcarkey];
                }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2])
                {
                    
vehid PlayerInfo[playerid][pPcarkey2];
                }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3])
                {
                    
vehid PlayerInfo[playerid][pPcarkey3];
                }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey4])
                {
                    
vehid PlayerInfo[playerid][pPcarkey4];
                }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey5])
                {
                    
vehid PlayerInfo[playerid][pPcarkey5];
                }
                else if(
GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey5] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey4] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey3] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey2] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey])
                {
                    
SendClientMessage(playeridCOLOR_GREY,"   You are not in your vehicle.");
                    return 
1;
                }
                if(
IsPlayerInVehicle(playeridvehid))
                {
                     
CarInfo[vehid][cPaintjob] = color1;
                    
SafeGivePlayerMoney(playerid, -5000);
                    
GameTextForPlayer(playerid"~w~Bill for a Paint Respray~n~~r~-$5000"50001);
                    
ChangeVehiclePaintjob(vehidcolor1);
                    
OnPropUpdate(4,vehid);
                    
OnPlayerUpdateEx(playerid);
                    return 
1;
                }
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_WHITE"HINT: (/v)ehicle [name]");
                
SendClientMessage(playeridCOLOR_WHITE"Available names: park, lock(1-2), sell, sellto, color, paintjob");
                return 
1;
            }
        }
        return 
1;
    } 



Re: Paintjob Help - kepa333 - 14.01.2013

bump.


Re: Paintjob Help - Diorturato - 14.01.2013

Firstly, debug it. Find the condition (you have many conditions, find only one), which says, "You are not in your vehicle" and check it.


Re: Paintjob Help - kepa333 - 14.01.2013

Not works.. Bump.


Re: Paintjob Help - Vince - 14.01.2013

Great! I love you people! But not really ...
Tell us what you did, what you already tried and what the values of the variables are. 'Not works' is not helpful! Actually, you should probably go read a tutorial on debugging while you're at it.


Re: Paintjob Help - Don_Cage - 14.01.2013

PHP код:
if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999 || PlayerInfo[playerid][pPcarkey3] == 9999 || PlayerInfo[playerid][pPcarkey4] == 9999 || PlayerInfo[playerid][pPcarkey5] == 9999
// This line was the problem, The || was supose to be && 
Here is fixed code,
PHP код:
           else if(strcmp(x_nr,"paintjob",true) == 0
            { 
                if(
PlayerInfo[playerid][pPcarkey] == 9999 && PlayerInfo[playerid][pPcarkey2] == 9999 && PlayerInfo[playerid][pPcarkey3] == 9999 && PlayerInfo[playerid][pPcarkey4] == 9999 && PlayerInfo[playerid][pPcarkey5] == 9999
                { 
                    
SendClientMessage(playeridCOLOR_GREY,"   You don't have a vehicle to respray."); 
                    return 
1
                } 
                if(!
IsAtDealership(playerid) && !IsAtPaySpray(playerid)) 
                { 
                    
SendClientMessage(playeridCOLOR_GREY,"* You must be at a Dealership or a Pay'n'Spray to do this!"); 
                    return 
1
                } 
                if(
GetPlayerMoney(playerid) < 5000
                { 
                    
SendClientMessage(playeridCOLOR_GREY,"   You don't have enough money for vehicle respray."); 
                    return 
1
                } 
                
tmp strtok(cmdtextidx); 
                if(!
strlen(tmp)) 
                { 
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /v paintjob [paintjob(0-3)]"); 
                    return 
1
                } 
                new 
color1
                
color1 strval(tmp); 
                if(
color1 && color1 3
                { 
                    
SendClientMessage(playeridCOLOR_GREY"   Wrong Paintjob id!"); 
                    return 
1
                } 
                new 
vehid
                if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) 
                { 
                    
vehid PlayerInfo[playerid][pPcarkey]; 
                } 
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) 
                { 
                    
vehid PlayerInfo[playerid][pPcarkey2]; 
                } 
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) 
                { 
                    
vehid PlayerInfo[playerid][pPcarkey3]; 
                } 
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey4]) 
                { 
                    
vehid PlayerInfo[playerid][pPcarkey4]; 
                } 
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey5]) 
                { 
                    
vehid PlayerInfo[playerid][pPcarkey5]; 
                } 
                else if(
GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey5] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey4] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey3] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey2] || GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pPcarkey]) 
                { 
                    
SendClientMessage(playeridCOLOR_GREY,"   You are not in your vehicle."); 
                    return 
1
                } 
                if(
IsPlayerInVehicle(playeridvehid)) 
                { 
                     
CarInfo[vehid][cPaintjob] = color1
                    
SafeGivePlayerMoney(playerid, -5000); 
                    
GameTextForPlayer(playerid"~w~Bill for a Paint Respray~n~~r~-$5000"50001); 
                    
ChangeVehiclePaintjob(vehidcolor1); 
                    
OnPropUpdate(4,vehid); 
                    
OnPlayerUpdateEx(playerid); 
                    return 
1
                } 
                return 
1
            } 
            else 
            { 
                
SendClientMessage(playeridCOLOR_WHITE"HINT: (/v)ehicle [name]"); 
                
SendClientMessage(playeridCOLOR_WHITE"Available names: park, lock(1-2), sell, sellto, color, paintjob"); 
                return 
1
            } 
        } 
        return 
1
    } 



Re: Paintjob Help - kepa333 - 15.01.2013

sure ty.