Amount of time in a vehicle..
#1

Hi, I was wondering how can a 'Amount of time in a vehicle be used'? When a player enters a vehicle, it starts of a count, When he gets off, it checks the amount of time the player was in the vehicle in seconds!
It then takes money away!

Ok, straight to the point: I want something like that ^ BUT using GetTickCount ( if possible )

Straight to the point comments only, all those side 1s, don't even bother!
Reply
#2

i dont suggest you to use GetTickCount because if your server will run 24 days without restart or smth then it will fu** your server up.

Use a repeated timer for a player.
pawn Код:
OnPlayerEnterVehicle
If(GetPlayerVehicleID(playerid,yourcarids))
SetTimerEx("Fuction",1000,1,"i",playerid);

forward Function(playerid);
public Function(playerid)
{
      GivePlayerMoney(playerid,-yourcash);
      //messages and other stuff
}

Edit:

Oops use Callback OnPlayerStateChange.
if(newstate == PLAYER_STATE_PASSENGER)
settimer...
Reply
#3

Quote:
Originally Posted by GaGlets®
Посмотреть сообщение
i dont suggest you to use GetTickCount because if your server will run 24 days without restart or smth then it will fu** your server up.

Use a repeated timer for a player.
pawn Код:
OnPlayerEnterVehicle
If(GetPlayerVehicleID(playerid,yourcarids))
SetTimerEx("Fuction",1000,1,"i",playerid);

forward Function(playerid);
public Function(playerid)
{
      GivePlayerMoney(playerid,-yourcash);
      //messages and other stuff
}
Yes, I had something like this, but I 'Heard' GetTickCount would be a better option. But anyways, I'll stick to this for now!
Reply
#4

onplayerstatechange.

settimerex 1 second,
PlayerInfo[playerid][timeinvehicle]++;
giveplayermoney(playerid,PlayerInfo[playerid][timeinvehicle]*yourammounthere

understand S
Reply
#5

Quote:
Originally Posted by The_Gangstas
Посмотреть сообщение
onplayerstatechange.

settimerex 1 second,
PlayerInfo[playerid][timeinvehicle]++;
giveplayermoney(playerid,PlayerInfo[playerid][timeinvehicle]*yourammounthere

understand S
Your option is totally wrong think real. You can supernaturally bug money with this, for example, with taxi job.

--Everytime you should check if player have enough money etc.
Reply
#6

exactly..? it was actually better than yours..?

heres peice of my code..

pawn Код:
public ThreeSecondTimer()
{
    foreach(Player,i)
    {
        if(PlayerInfo[i][DriverDuty] == 1)
        {
            new vehicle = GetPlayerVehicleID(i);
            foreach(Player,j)
            {
                if(IsPlayerInAnyVehicle(j) && GetPlayerVehicleID(j) == vehicle && GetPlayerState(j) == PLAYER_STATE_PASSENGER)
                {
                    if(SafeGetPlayerMoney(j) >= PlayerInfo[i][DriverFare])
                    {
                        PlayerInfo[j][Money] -= PlayerInfo[i][DriverFare];
                        PlayerInfo[i][Money] += PlayerInfo[i][DriverFare];
                        PlayerInfo[i][TotalIncome]+=PlayerInfo[i][DriverFare];
                        new tstr[50];
                        format(tstr,sizeof(tstr),"~b~Income~w~:~g~$%d",PlayerInfo[i][TotalIncome]);
                        TextDrawSetString(DriverText[i],tstr);
                    }
                    else if(SafeGetPlayerMoney(j) < PlayerInfo[i][DriverFare])
                    {
                        RemovePlayerFromVehicle(j);
                        SendClientMessage(j,COLOR_RED,"Ejected: You've Been Ejected From The Driver's Vehicle For Not Being Able To Afford His Fare!");
                        new str[95];
                        format(str,sizeof(str),"Ejected:%s(%d) Could Not Afford Your Fare, He Has Been Ejected!");
                        SendClientMessage(i,COLOR_RED,str);
                    }
                }
            }
        }
    }
    return 1;
}
look at this as soon has a person enters a drivers car, it starts, instead of a command.

pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_PASSENGER)
    {
        if(IsPlayerInDriverVehicle(playerid))
        {
            if(IsDriverATaxiDriver(GetPlayerVehicleID(playerid)))
            {
                new driverid = GetVehDriverID(GetPlayerVehicleID(playerid));
                if(driverid != -1)
                {
                    if(PlayerInfo[driverid][DriverDuty] == 1)
                    {
                        new str[128];
                        format(str,sizeof(str),"Public: You Entered %s(%d)'s Taxi, You Will Be Charged $%d Per 3 Seconds!",Playername(driverid),driverid,PlayerInfo[driverid][DriverFare]);
                        SendClientMessage(playerid,LIME,str);
                        format(str,sizeof(str),"%s(%d) Has Entered Your Vehicle. Will Be Charged $%d Per 3 Seconds",Playername(playerid),playerid,PlayerInfo[driverid][DriverFare]);
                        SendClientMessage(driverid,LIME,str);
                        TextDrawShowForPlayer(driverid,DriverBox[driverid]);
                        TextDrawShowForPlayer(driverid,DriverStatText[driverid]);
                        TextDrawShowForPlayer(driverid,DriverText[driverid]);
                    }
                }
            }
        }
and when they exit. it automatically stops. L
Reply
#7

G... and what you mean by that?

I just wrote that youre first example was totaly wrong.
And that crap a bit upper is damned copy of goadfather/edit.

I see your damned GM have anticheat which is piece of shit or even its a freaking renamed function and that eats your fa***** GMode memory.
Reply
#8

how the hell is that godfather copied? i don't even run a role-play game-mode?

what anti-cheat? theres no anti-cheat in there. get out idiot.

oh u mean safegetplayermoney?

pawn Код:
public SafeGetPlayerMoney(playerid)
{
    return PlayerInfo[playerid][Money];
}
?? wtf is wrong with u? i corrected u, I'm right your wrong. chill out.

my first example was not wrong. you just didn't understand
Reply
#9

Yes maybe now i dont understand you because you are using snipplets or how to call that `u` try to learn how to write man.
Dont add visitor messages on my profile only because you are so envious. Yes i am better than you yes and i can proove it, yes we an make script duels - who will make better script with theme. Just keep you fingers away from keybroad. And yes as i wrote, an useful function which eats memory.
Reply
#10

english comes first kid.

i made all that.. L. im done. idiot im not gonna start a flame war. gtfo, you fail.

you used onplayerentervehicle first L then u saw me right onplayerstatechange then u edited urs. kid gtfo

done-.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)