Help me with /beginevent command
#1

Код:
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
Reply
#2

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

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 ?
Reply
#4

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;

Reply
#5

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

Anyone help me ?
Reply
#7

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

I think this is the only one can make the problem hix
Reply
#9

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, ...};
Reply
#10

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, ...};
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)