Problem with check bool
#1

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.
Reply
#2

bump, help
Reply
#3

anyone can
Reply
#4

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"));
}
    }
Reply
#5

not work.

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

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"));
}
    }
Reply
#7

still
Reply
#8

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"));
}
    }
Reply
#9

that same
Reply
#10

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.
Reply
#11

I reversed the if

he wants to despawn the car
Reply
#12

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

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

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

changed, but still working bad
Reply
#15

Explain how it behaves now.
Reply
#16

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.
Reply
#17

whos know
Reply
#18

oh come on, noone can?
Reply
#19

bump!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)