SA-MP Forums Archive
Problem with check bool - 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: Problem with check bool (/showthread.php?tid=524544)



Problem with check bool - cnoopers - 07.07.2014

should spawn car when bool value is true and if false, unspawn but vehicle always spawn
whats wrong

Код:
        new bool:veh1spawned[MAX_PLAYERS]; //global
        new Float:x, Float:y, Float:z, Float:angle;
        new Float:x2, Float:y2;
        new vehid[MAX_PLAYERS];

//case in dialog response
                    if(veh1spawned[playerid] == false)
                    {
	                    veh1spawned[playerid] = true;
						GetXYInFrontOfPlayer(playerid, x, y, 10.0);
						GetPlayerPos(playerid, x2, y2, z);
						GetPlayerFacingAngle(playerid, angle);
						vehid[playerid] = CreateVehicle(Veh1[playerid], x, y, z, angle+90, 0, 0, -1);
						SetPVarInt(playerid, "veh1spawned", Veh1[playerid]);
					}else if(veh1spawned[playerid] == true)
					{
					    veh1spawned[playerid] = false;
					    DestroyVehicle(vehid[playerid]);
					}

//opc
	if(veh1spawned[playerid] == true)
	{
	    veh1spawned[playerid] = false;
	    DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
	}

//opd
	if(veh1spawned[playerid] == true)
	{
	    veh1spawned[playerid] = false;
	    DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
	}
//edit
so if i add sendclientmessage after true or false such as 'vehicle spawned' or 'vehicle unspawned' it will be displayed correctly.


Re: Problem with check bool - cnoopers - 07.07.2014

bump, help


Re: Problem with check bool - cnoopers - 07.07.2014

anyone can


Re: Problem with check bool - ShinichiKudou - 07.07.2014

try looping it
pawn Код:
new bool:veh1spawned[MAX_PLAYERS]; //global
        new Float:x, Float:y, Float:z, Float:angle;
        new Float:x2, Float:y2;
        new vehid[MAX_PLAYERS];

//case in dialog response
                    if(veh1spawned[playerid] == false)
                    {
{
                                            veh1spawned[playerid] = true;
                        GetXYInFrontOfPlayer(playerid, x, y, 10.0);
                        GetPlayerPos(playerid, x2, y2, z);
                        GetPlayerFacingAngle(playerid, angle);
                        vehid[playerid] = CreateVehicle(Veh1[playerid], x, y, z, angle+90, 0, 0, -1);
                        SetPVarInt(playerid, "veh1spawned", Veh1[playerid]);
}                  
}
else if(veh1spawned[playerid] == true)
                    {
{
                        veh1spawned[playerid] = false;
                        DestroyVehicle(vehid[playerid]);
}
                    }

//opc
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }

//opd
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }



Re: Problem with check bool - cnoopers - 07.07.2014

not work.

now its like:
first click - spawn, second click - nothing, third click - spawn, etc.


Re: Problem with check bool - ShinichiKudou - 07.07.2014

pawn Код:
new bool:veh1spawned[MAX_PLAYERS]; //global
        new Float:x, Float:y, Float:z, Float:angle;
        new Float:x2, Float:y2;
        new vehid[MAX_PLAYERS];

//case in dialog response
                    if(veh1spawned[playerid] == false)
                    {
{
                                            veh1spawned[playerid] = true;
                        GetXYInFrontOfPlayer(playerid, x, y, 10.0);
                        GetPlayerPos(playerid, x2, y2, z);
                        GetPlayerFacingAngle(playerid, angle);
                        vehid[playerid] = CreateVehicle(Veh1[playerid], x, y, z, angle+90, 0, 0, -1);
                        SetPVarInt(playerid, "veh1spawned", Veh1[playerid]);
}                  
}
else
                    {
{
                        veh1spawned[playerid] = false;
                        DestroyVehicle(vehid[playerid]);
}
                    }

//opc
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }

//opd
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }



Re: Problem with check bool - cnoopers - 07.07.2014

still


Re: Problem with check bool - ShinichiKudou - 07.07.2014

pawn Код:
new bool:veh1spawned[MAX_PLAYERS]; //global
        new Float:x, Float:y, Float:z, Float:angle;
        new Float:x2, Float:y2;
        new vehid[MAX_PLAYERS];

//case in dialog response
if(veh1spawned[playerid] == true)
                    {
{
                        veh1spawned[playerid] = false;
                        DestroyVehicle(vehid[playerid]);
}
                    }
                    else
                    {
{
                                            veh1spawned[playerid] = true;
                        GetXYInFrontOfPlayer(playerid, x, y, 10.0);
                        GetPlayerPos(playerid, x2, y2, z);
                        GetPlayerFacingAngle(playerid, angle);
                        vehid[playerid] = CreateVehicle(Veh1[playerid], x, y, z, angle+90, 0, 0, -1);
                        SetPVarInt(playerid, "veh1spawned", Veh1[playerid]);
}                  
}


//opc
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }

//opd
    if(veh1spawned[playerid] == true)
    {
{
        veh1spawned[playerid] = false;
        DestroyVehicle(GetPVarInt(playerid, "Veh1spawned"));
}
    }



Re: Problem with check bool - cnoopers - 07.07.2014

that same


Respuesta: Re: Problem with check bool - Siralos - 07.07.2014

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
not work.

now its like:
first click - spawn, second click - nothing, third click - spawn, etc.
That's not what you want? Please explain how you want it to work.


Re: Problem with check bool - ShinichiKudou - 07.07.2014

I reversed the if

he wants to despawn the car


Re: Problem with check bool - cnoopers - 07.07.2014

i want spawn vehicle when it is unspawned and unspawn when its spawned


Respuesta: Problem with check bool - Siralos - 07.07.2014

SetPVarInt(playerid, "veh1spawned", Veh1[playerid]);

It should be called with vehid[playerid], not with Veh1[playerid]


Re: Problem with check bool - cnoopers - 07.07.2014

changed, but still working bad


Respuesta: Problem with check bool - Siralos - 07.07.2014

Explain how it behaves now.


Re: Problem with check bool - cnoopers - 07.07.2014

when i clicked an option in dialog, vehicle will spawn. at the next click that car should destroy, but then happens nothing. at the third click, next car will be spawned.


Re: Problem with check bool - cnoopers - 07.07.2014

whos know


Re: Problem with check bool - cnoopers - 07.07.2014

oh come on, noone can?


Re: Problem with check bool - cnoopers - 08.07.2014

bump!