Timer dont work
#1

Hey guys, i was continuing me rcxd system and well something isnt working quite well.

Well its not working at all.

When i enter a rc car and automattically set my car health to 799.0 it dosen't destroy my vehicle and input a message idk why?

any one know why? heres my timer:

pawn Код:
SetTimer("CheckRCXD", 500, 1);
pawn Код:
public CheckRCXD()
{
    new Float: VehHealth, currentveh;
    LoopPlayers(i)
    {
        if(GetPlayerVehicleID(i) == 411)
        {
            currentveh = GetPlayerVehicleID(i);
            GetVehicleHealth(currentveh, VehHealth);
            if(VehHealth < 800.0)
            {
                if(IsInRCXD[i] == true) {
                    SendClientMessage(i, COLOR_YELLOW, "Your RC-XD has exploded");
                }
                DestroyVehicle(currentveh);
            }
        }
    }
    return 1;
}
Reply
#2

I assume you want to check if the vehicle model is 411, not if the vehicle id is 411, they are both completely different things. Therefore your check needs to be fixed like so:

pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(i)) == 411)
Reply
#3

Even though i did what you said and it still dont work -.-'

pawn Код:
dcmd_hi(playerid, params[])
{
    #pragma unused params
    new currentveh;
    currentveh = GetPlayerVehicleID(playerid);
    SetVehicleHealth(currentveh, 799.0);
    return 1;
}
Thats my command to set the health lower although i dont think thats got anything to do with it.
Reply
#4

What is this variable? IsInRCXD?

If it's storing what it sounds like it is, then it's redundant.
Reply
#5

Its called when the player places a rcxd, although ill simplify my question and say that its not destroying my vehicle.
Reply
#6

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Its called when the player places a rcxd, although ill simplify my question and say that its not destroying my vehicle.
Did you create the vehicle using CreateVehicle?
Reply
#7

It happens to me too something similar:
When i am ID 0 the timer works.
Else it doesnt works.
Its a sa-mp bug.
You should use other methods.
Reply
#8

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
It happens to me too something similar:
When i am ID 0 the timer works.
Else it doesnt works.
Its a sa-mp bug.
You should use other methods.
I doubt that, again I think you're making the same mistake that I'm seeing around these forums constantly these days with people making timers. You're doing something like this:

pawn Код:
SetTimer("KillPlayer",10000,false);

public KillPlayer(playerid)
{    
    SetPlayerHealth(playerid,0);
    return 1;
}
Well of course that's only going to work for "ID 0", because the parameter playerid in the "KillPlayer" function is not being set to anything, so it's defaulting to 0. You need to pass the playerid to it in order for it to work:

pawn Код:
SetTimerEx("KillPlayer",10000,false,"i",playerid);

public KillPlayer(playerid)
{    
    SetPlayerHealth(playerid,0);
    return 1;
}
Additionally if you want to kill everyone in the server with a timer, then you would just use a loop in the function, like so:

pawn Код:
SetTimer("KillAll",10000,false);

public KillAll()
{
    for(new i; i < MAX_PLAYERS; i++) SetPlayerHealth(i,0);
    return 1;
}
This is all a bit off-topic but I hope it helps you make sense of how to use timers a little more, and about passing information to functions using SetTimerEx.
Reply
#9

Ok i made it on OnPlayerUpdate,

yes im using createvehicle.

CreateVehicle(441,x,y,z,0,0,0,0);

and yer still fails
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)