SA-MP Forums Archive
Help me with /beginevent command - 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 me with /beginevent command (/showthread.php?tid=605607)



Help me with /beginevent command - Kenxxx - 22.04.2016

Код:
cmd:beginevent(playerid, params[])
{
        new rand = Random(1, 99);
	if(EventCars[rand] == INVALID_VEHICLE_ID)
        {
	        new Float:x, Float:y, Float:z;
		new Float:Angle;
		GetPlayerFacingAngle(i, Angle);
		GetPlayerPos(i, x, y, z);
		EventCars[rand] = CreateVehicle(Events[EventCar], x,y,z+2,Angle,-1,-1,VEHICLE_RESPAWN);
		VehicleFuel[EventCars[rand]] = 100.0;
		Vehicle_ResetData(EventCars[rand]);
		PutPlayerInVehicle(i, EventCars[rand], 0);
		SetPlayerHealth(i, Events[Health]);
		SetPlayerArmor(i, Events[Armor]);
		CarShooting[i] = 1;

	}
}

new EventCars[100] = INVALID_VEHICLE_ID;
I dont know why but when I set up all the event type and bla bla bla. Then I use /beginevent to create a car then I can enjoy my event. But when I use /beginevent there's nothing happen. I dont know why ? Please help me


Re: Help me with /beginevent command - XtremeRz - 22.04.2016

You didn't return a value

Do it by typing "return 1;" end of the if, and another "return 1;" at the end of the CMD

Tell me what's happen after you do this.


Re: Help me with /beginevent command - Kenxxx - 22.04.2016

Quote:
Originally Posted by XtremeRz
Посмотреть сообщение
You didn't return a value

Do it by typing "return 1;" end of the if, and another "return 1;" at the end of the CMD

Tell me what's happen after you do this.
Код:
if(EventCars[rand] == INVALID_VEHICLE_ID)
{
	new Float:x, Float:y, Float:z;
	new Float:Angle;
	GetPlayerFacingAngle(i, Angle);
	GetPlayerPos(i, x, y, z);
	EventCars[rand] = CreateVehicle(Events[EventCar], x,y,z+2,Angle,-1,-1,VEHICLE_RESPAWN);
	VehicleFuel[EventCars[rand]] = 100.0;
	Vehicle_ResetData(EventCars[rand]);
	PutPlayerInVehicle(i, EventCars[rand], 0);
	SetPlayerHealth(i, Events[Health]);
	SetPlayerArmor(i, Events[Armor]);
	CarShooting[i] = 1;
        return 1;
}
Like this ?


Re: Help me with /beginevent command - oMa37 - 22.04.2016

Like this

PHP код:
CMD:beginevent(playeridparams[])
{
        new 
rand Random(199);
    if(
EventCars[rand] == INVALID_VEHICLE_ID)
        {
            new 
Float:xFloat:yFloat:z;
        new 
Float:Angle;
        
GetPlayerFacingAngle(iAngle);
        
GetPlayerPos(ixyz);
        
EventCars[rand] = CreateVehicle(Events[EventCar], x,y,z+2,Angle,-1,-1,VEHICLE_RESPAWN);
        
VehicleFuel[EventCars[rand]] = 100.0;
        
Vehicle_ResetData(EventCars[rand]);
        
PutPlayerInVehicle(iEventCars[rand], 0);
        
SetPlayerHealth(iEvents[Health]);
        
SetPlayerArmor(iEvents[Armor]);
        
CarShooting[i] = 1;
               return 
1;
    }
        return 
1;




Re: Help me with /beginevent command - Kenxxx - 22.04.2016

Quote:
Originally Posted by XtremeRz
Посмотреть сообщение
You didn't return a value

Do it by typing "return 1;" end of the if, and another "return 1;" at the end of the CMD

Tell me what's happen after you do this.
Still not working, when I use /beginevent then nothing happened again..


Re: Help me with /beginevent command - Kenxxx - 22.04.2016

Anyone help me ?


Re: Help me with /beginevent command - Sew_Sumi - 22.04.2016

Have you got any other commands, or is this the only one.

And are those commands also fast commands, or are they through OnPlayerCommandText because you can't mix them as this will happen.


Re: Help me with /beginevent command - Kenxxx - 22.04.2016

I think this is the only one can make the problem hix


Re: Help me with /beginevent command - Konstantinos - 22.04.2016

Declaring as:
pawn Код:
new EventCars[100] = INVALID_VEHICLE_ID;
sets only index 0 to INVALID_VEHICLE_ID and all the rest are 0. Then the if statement is never true unless rand is 0 so the code inside never gets executed. Replace with:
pawn Код:
new EventCars[100] = {INVALID_VEHICLE_ID, ...};



Re: Help me with /beginevent command - Kenxxx - 22.04.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Declaring as:
pawn Код:
new EventCars[100] = INVALID_VEHICLE_ID;
sets only index 0 to INVALID_VEHICLE_ID and all the rest are 0. Then the if statement is never true unless rand is 0 so the code inside never gets executed. Replace with:
pawn Код:
new EventCars[100] = {INVALID_VEHICLE_ID, ...};
I don't know why but still not working
I also use

pawn Код:
new EventCars[100] = {INVALID_VEHICLE_ID, ...};