CMD affect all players
#1

Hello!

This cmd affects all player that sitting in a vehicle, and not only for the one that types the cmd.
How do i fix that correct?
CODE:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/load",true))
    {
        new id = GetPlayerVehicleID(playerid);
        new
            Float:x,
            Float:y,
            Float:z;

        GetPlayerPos(playerid,x,y,z);

        AddVehicleMissiles(id,2.0,-1.05,0.0);
        return 1;
    }
    return 0;
}
And when someone press fire that didnt use the /load cmd, it fire one rocket from hes own vehicle and removes one rocket for the one who used the cmd.
How to fix that correct?
CODE:
pawn Код:
public VM_OnPlayerKeyStateChange(playerid,newkeys)
{
    if((newkeys & MISSILE_FIRE_KEY) == (MISSILE_FIRE_KEY))
    {
        new id = GetPlayerVehicleID(playerid);
        if(!VehicleFire[id])
        {
            if(id)
            {
                if(IsValidObject(VehicleBomb[id][1]))
                {
                    new
                    Float:x,
                    Float:y,
                    Float:z,
                    Float:a;


                    VehicleFire[id] = 1;

                    if(IsValidObject(VehicleBomb[id][0]))
                    {
                        DestroyObject(VehicleBomb[id][0]);

                        GetVehiclePos(id,x,y,z);
                        GetVehicleZAngle(id,a);

                        a += 270;
                        z += VehicleOffsetZ[id];

                        x += (VehicleOffsetX[id] * floatsin(-a, degrees));
                        y += (VehicleOffsetX[id] * floatcos(-a, degrees));

                        VehicleBomb[id][0] = CreateObject(3790,x,y,z,2,0,a,300.0);
                        VehicleSmok[id][0] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

                        a += 90;

                        x += (300 * floatsin(-a, degrees));
                        y += (300 * floatcos(-a, degrees));

                        MoveObject(VehicleBomb[id][0],x,y,z,MISSILE_SPEED);
                        MoveObject(VehicleSmok[id][0],x,y,z-1.3,MISSILE_SPEED);

                        SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,0);
                        VM_OnVehicleFire(id,0);
                        return 1;
                    }
                    DestroyObject(VehicleBomb[id][1]);

                    GetVehiclePos(id,x,y,z);
                    GetVehicleZAngle(id,a);

                    a += 90;
                    z += VehicleOffsetZ[id];

                    x += (VehicleOffsetX[id] * floatsin(-a, degrees));
                    y += (VehicleOffsetX[id] * floatcos(-a, degrees));

                    VehicleBomb[id][1] = CreateObject(3790,x,y,z,2,0,a+180,300.0);
                    VehicleSmok[id][1] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

                    a += 270;

                    x += (300 * floatsin(-a, degrees));
                    y += (300 * floatcos(-a, degrees));

                    MoveObject(VehicleBomb[id][1],x,y,z,MISSILE_SPEED);
                    MoveObject(VehicleSmok[id][1],x,y,z-1.3,MISSILE_SPEED);

                    SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,1);
                    VM_OnVehicleFire(id,1);
                    return 1;
                    }
                }
            return 1;
        }
    }
    return 1;
}
Reply
#2

try this

Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/load",true))
    {
	    if(IsPlayerInAnyVehicle(playerid))
		{
	        new id = GetPlayerVehicleID(playerid);
	        new
	            Float:x,
	            Float:y,
	            Float:z;

	        GetPlayerPos(playerid,x,y,z);

	        AddVehicleMissiles(id,2.0,-1.05,0.0);
	        return 1;
	    }
	    return 0;
	}
Код:
public VM_OnPlayerKeyStateChange(playerid,newkeys)
{
    if((newkeys & MISSILE_FIRE_KEY) == (MISSILE_FIRE_KEY))
    {
	    if(IsPlayerInAnyVehicle(playerid))
		{
	        new id = GetPlayerVehicleID(playerid);
	        if(!VehicleFire[id])
	        {
	            if(id)
	            {
	                if(IsValidObject(VehicleBomb[id][1]))
	                {
	                    new
	                    Float:x,
	                    Float:y,
	                    Float:z,
	                    Float:a;


	                    VehicleFire[id] = 1;

	                    if(IsValidObject(VehicleBomb[id][0]))
	                    {
	                        DestroyObject(VehicleBomb[id][0]);

	                        GetVehiclePos(id,x,y,z);
	                        GetVehicleZAngle(id,a);

	                        a += 270;
	                        z += VehicleOffsetZ[id];

	                        x += (VehicleOffsetX[id] * floatsin(-a, degrees));
	                        y += (VehicleOffsetX[id] * floatcos(-a, degrees));

	                        VehicleBomb[id][0] = CreateObject(3790,x,y,z,2,0,a,300.0);
	                        VehicleSmok[id][0] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

	                        a += 90;

	                        x += (300 * floatsin(-a, degrees));
	                        y += (300 * floatcos(-a, degrees));

	                        MoveObject(VehicleBomb[id][0],x,y,z,MISSILE_SPEED);
	                        MoveObject(VehicleSmok[id][0],x,y,z-1.3,MISSILE_SPEED);

	                        SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,0);
	                        VM_OnVehicleFire(id,0);
	                        return 1;
	                    }
	                    DestroyObject(VehicleBomb[id][1]);

	                    GetVehiclePos(id,x,y,z);
	                    GetVehicleZAngle(id,a);

	                    a += 90;
	                    z += VehicleOffsetZ[id];

	                    x += (VehicleOffsetX[id] * floatsin(-a, degrees));
	                    y += (VehicleOffsetX[id] * floatcos(-a, degrees));

	                    VehicleBomb[id][1] = CreateObject(3790,x,y,z,2,0,a+180,300.0);
	                    VehicleSmok[id][1] = CreateObject(18731,x,y,z-1.3,0,0,0,300.0);

	                    a += 270;

	                    x += (300 * floatsin(-a, degrees));
	                    y += (300 * floatcos(-a, degrees));

	                    MoveObject(VehicleBomb[id][1],x,y,z,MISSILE_SPEED);
	                    MoveObject(VehicleSmok[id][1],x,y,z-1.3,MISSILE_SPEED);

	                    SetTimerEx("VM_Explode",MISSILE_DETONATE_TIME,0,"dd",id,1);
	                    VM_OnVehicleFire(id,1);
	                    return 1;
	                    }
	                }
	            return 1;
	        }
	    }
	    return 1;
	}
Reply
#3

It still not work properly, if you type /load, you get 2 rockets, if then someone else press the fire button, he fires one rocket that he shouldnt have at all. It is like hes stealing one rocket from the one thats have the rockets and shoot it from hes vehicle instead, then the one with the rockets loose one and can only shoot the last one.

You only steals rocket ID[0], rocket ID[1] still remains unused for the one that loaded the rockets.
I hope i explained good enough.
Reply
#4

Quote:
Originally Posted by cruising
Посмотреть сообщение
It still not work properly, if you type /load, you get 2 rockets, if then someone else press the fire button, he fires one rocket that he shouldnt have at all. It is like hes stealing one rocket from the one thats have the rockets and shoot it from hes vehicle instead, then the one with the rockets loose one and can only shoot the last one.

You only steals rocket ID[0], rocket ID[1] still remains unused for the one that loaded the rockets.
I hope i explained good enough.
I will check it again and find out whats the problem
Reply
#5

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
I will check it again and find out whats the problem
Thank you! I appreciate that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)