SA-MP Forums Archive
HELP[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)
+--- Thread: HELP[Problem] (/showthread.php?tid=337023)



HELP[Problem] - Dan_Barocu - 24.04.2012

a frined gave me a cool thing..and doesent work well im supposed to see car interior but sometimes when i go in car i dont see car interior please help!

PHP код:
                if(newstate == PLAYER_STATE_DRIVER)
                {
                if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");
                {
                if(
GetPVarInt(playerid,"used") == 0)
                {
                new 
car GetPlayerVehicleID(playerid);
                
obj[playerid] = CreatePlayerObject(playerid,193000.0000, -1282.998410.14930.0000, -1, -1100);
                
AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.1950000.5100000.0000000.0000000.000000);
                
AttachCameraToPlayerObject(playerid,obj[playerid]);
                
SetPVarInt(playerid,"used",1);
                }
                else if(
GetPVarInt(playerid,"used") == 1)
                {
                
SetCameraBehindPlayer(playerid);
                
DestroyPlayerObject(playerid,obj[playerid]);
                
SetPVarInt(playerid,"used",0);
                }
                } 



Re: HELP[Problem] - Ballu Miaa - 24.04.2012

There were lot of loose braces in your code and even loose indentation.

Try this one:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
                {
                        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");
                        if(GetPVarInt(playerid,"used") == 0)
                        {
                            new car = GetPlayerVehicleID(playerid);
                            obj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
                            AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
                            AttachCameraToPlayerObject(playerid,obj[playerid]);
                            SetPVarInt(playerid,"used",1);
                        }
                        else if(GetPVarInt(playerid,"used") == 1)
                        {
                          SetCameraBehindPlayer(playerid);
                          DestroyPlayerObject(playerid,obj[playerid]);
                          SetPVarInt(playerid,"used",0);
                        }
                        return 1;
                }



Re: HELP[Problem] - Dan_Barocu - 24.04.2012

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
There were lot of loose braces in your code and even loose indentation.

Try this one:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
                {
                        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");
                        if(GetPVarInt(playerid,"used") == 0)
                        {
                            new car = GetPlayerVehicleID(playerid);
                            obj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
                            AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
                            AttachCameraToPlayerObject(playerid,obj[playerid]);
                            SetPVarInt(playerid,"used",1);
                        }
                        else if(GetPVarInt(playerid,"used") == 1)
                        {
                          SetCameraBehindPlayer(playerid);
                          DestroyPlayerObject(playerid,obj[playerid]);
                          SetPVarInt(playerid,"used",0);
                        }
                        return 1;
                }

pawno stops responding need to take out return 1; and its all same..i put it at OnPlayerStateChange
EDIT:need brackets doesent work how you did it sorry


Re: HELP[Problem] - Dan_Barocu - 24.04.2012

anyone knows from this full forum?


Re: HELP[Problem] - Dan_Barocu - 24.04.2012

bumb sorry


Re: HELP[Problem] - Pinguinn - 24.04.2012

Debug to find out the problem.
Debugging Guide


Re: HELP[Problem] - ViniBorn - 24.04.2012

Try this
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");

    if(!GetPVarInt(playerid,"used"))
    {
        new car = GetPlayerVehicleID(playerid);
        obj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
        AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
        AttachCameraToPlayerObject(playerid,obj[playerid]);
        SetPVarInt(playerid,"used",1);
    }
    else
    {
        SetCameraBehindPlayer(playerid);
        DestroyPlayerObject(playerid,obj[playerid]);
        SetPVarInt(playerid,"used",0);
    }
}



Re: HELP[Problem] - Dan_Barocu - 24.04.2012

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Try this
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");

    if(!GetPVarInt(playerid,"used"))
    {
        new car = GetPlayerVehicleID(playerid);
        obj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
        AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
        AttachCameraToPlayerObject(playerid,obj[playerid]);
        SetPVarInt(playerid,"used",1);
    }
    else
    {
        SetCameraBehindPlayer(playerid);
        DestroyPlayerObject(playerid,obj[playerid]);
        SetPVarInt(playerid,"used",0);
    }
}
i tried it and pawno keeps stop responding..


Re: HELP[Problem] - Dan_Barocu - 24.04.2012

how do i debug the code thingy??


Re: HELP[Problem] - Dan_Barocu - 24.04.2012

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Try this
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
                {
                    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"Trebuie sa fiti la volan.");
                    printf("DEBUG: Volan");
                    if(!GetPVarInt(playerid,"used"))
                    {
                        new car = GetPlayerVehicleID(playerid);
                        obj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
                        AttachPlayerObjectToVehicle(playerid,obj[playerid],car,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
                        AttachCameraToPlayerObject(playerid,obj[playerid]);
                        SetPVarInt(playerid,"used",1);
                    }
                    else
                    {
                        SetCameraBehindPlayer(playerid);
                        DestroyPlayerObject(playerid,obj[playerid]);
                        SetPVarInt(playerid,"used",0);
                    }
                }
like this?