GetPlayerVelocity ?
#1

Hi everyone. how can i make that you earn money from how much you drive,
instead of a timer? i hope you can help me

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
        {
            stimer = SetTimerEx("Sweeping", WAIT_TIME, true, "d", playerid);
            SendClientMessage(playerid, 0x58E11EC8, "You are now Street Sweeping to earn money. Drive around and earn money!");
        }
       
    }
    return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(GetVehicleModel(vehicleid) == 574)
    {
        KillTimer(stimer);
        SendClientMessage(playerid, 0x58E11EC8, "You are no longer doing your Street Sweeping Job!");
    }
    return 1;
}


forward Sweeping(playerid);
public Sweeping(playerid)
{
    new string[128];
    new rand = 200 + random(210);
    GivePlayerMoney(playerid, rand);
    format(string, sizeof(string), "You have received $%d for your Street Sweeping Job!", rand);
    SendClientMessage(playerid, 0x58E11EC8, string);
    return 1;
}
Reply
#2

or some other way to check if the sweeper is moving, so you can not just earn money when you are not sweeping?
Reply
#3

Have u tried the code?
Reply
#4

Yes i have tried it, but i can just get in a sweeper and ALT tab the game for long time, and when i come back i have just earned alot of money. but i dont know how to make that it will detect if you are moving.. also so you only will earn money when you are driving around
Reply
#5

Код:
new
    Float: vX,
    Float: vY,
    Float: vZ;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
if (vX > 0 || xY > 0 || vZ > 0)
{
    // Player is moving
}
This detects if the player is moving or not.

I'm not sure if it works perfectly when the player is AFK, because when you press pause when driving, you continue to move on other players' screens.
Reply
#6

Okay, but how to make that it will stop counting money when the player is not moving?
Reply
#7

Anyone?
Reply
#8

Код:
else return 0;
Reply
#9

What do you mean?
Reply
#10

Код:
new
    Float: vX,
    Float: vY,
    Float: vZ;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
if (vX > 0 || xY > 0 || vZ > 0)
{
    // Count the money (player is moving)
} else return 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)