Speed cam
#1

I made for the speedcam thing, something that gives you a ticket, you can either pay the ticket or don't pay the ticket.
look:
pawn Код:
for(new i; i != sizeof gObjects90; ++i) {
        if(IsPlayerInRangeOfPoint(playerid, 25.0, gObjects90[i][0], gObjects90[i][1], gObjects90[i][2])) {
            if(IsFlashed[playerid] == 0)
            {
                new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[300],final_speed_int,speed_string2[300];
                new vehicleid;
                vehicleid = GetPlayerVehicleID(playerid);
               
                SendClientMessage(playerid,COLOR_RED, " ");
                GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
                final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
                final_speed_int = floatround(final_speed,floatround_round);
                format(speed_string,300,"* U were driving {FF6347}%i{FF0000}, while U were only allowed to drive {FF6347}90{FF0000}KPH, For that U must pay: ${FF6347}%i{FF0000}",final_speed_int, final_speed_int*2);
                //format(string,sizeof(string),"U were driving %i, while U were only allowed to drive 90KPH, For that U lost: %i bucks",vehspeed,vehspeed*2);
                SendClientMessage(playerid,COLOR_RED, speed_string);
                GameTextForPlayer(playerid,"~r~B~y~U~b~S~g~T~w~E~p~D",5000,3);
               
                //Dialog om te betalen
                format(speed_string2,300,"{FFFFFF}U must pay: ${FF6347}%i{FFFFFF}\nBecause You were Driving {FF6347}%i{FFFFFF}Faster than allowed!\n\nIf you don't pay, U will becoma a suspect!",final_speed_int*2,final_speed_int-90);
                ShowPlayerDialog(playerid,DIALOG_PAYME,DIALOG_STYLE_MSGBOX,"Speed Cam",speed_string2,"Pay","Fuck off!");
               
                camflash(playerid);
                SetTimerEx("resflashed",3000,false,"i",playerid);
                IsFlashed[playerid] = 1;
            }
        }
    }
and

pawn Код:
//==============================================================================
//Pay ticket when flashed
//==============================================================================
    if(dialogid == DIALOG_PAYME)
    {
        if(!response)
        {
            //Will make that later
        }
        else
        {
            //here I need the pay ticket stuff
        }
    }
well, how can I use the amount of money used under OnPlayerUpdate, and use it in my OnDialogResponse?
I need the finalspeed_int*2 amount, to be able to use anywhere in my GM :/
Reply
#2

I think that you must use
pawn Код:
SetTimerEx("resflashed",3000, true, "i",playerid);
to set the time repeating.

Have a nice day !
Reply
#3

Thanks for the nice, day anyways, I solved it already, I'm sorry :/
I don't think I must repeat the timer, because then there might be a possibility that when I just passed the cam the timer might be on 0.5 seconds, f.E. so yeah...
Reply
#4

Quote:
Originally Posted by knackworst
Посмотреть сообщение
Thanks for the nice, day anyways, I solved it already, I'm sorry :/
I don't think I must repeat the timer, because then there might be a possibility that when I just passed the cam the timer might be on 0.5 seconds, f.E. so yeah...
Allright, good that you got it fixed out, could you post the code how you fixed it so I could take a look at it and maybe learn from it?

Have a nice day !
Reply
#5

Well, I just removed the break... it didn't let me pass the other objects
anyways, now you are here, (i dont wanna go off-topic but I don't wanna thread post whore either)
can you help me with this?
I made for the speedcam thing, something that gives you a ticket, you can either pay the ticket or don't pay the ticket.
look:
pawn Код:
for(new i; i != sizeof gObjects90; ++i) {
        if(IsPlayerInRangeOfPoint(playerid, 25.0, gObjects90[i][0], gObjects90[i][1], gObjects90[i][2])) {
            if(IsFlashed[playerid] == 0)
            {
                new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[300],final_speed_int,speed_string2[300];
                new vehicleid;
                vehicleid = GetPlayerVehicleID(playerid);
               
                SendClientMessage(playerid,COLOR_RED, " ");
                GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
                final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
                final_speed_int = floatround(final_speed,floatround_round);
                format(speed_string,300,"* U were driving {FF6347}%i{FF0000}, while U were only allowed to drive {FF6347}90{FF0000}KPH, For that U must pay: ${FF6347}%i{FF0000}",final_speed_int, final_speed_int*2);
                //format(string,sizeof(string),"U were driving %i, while U were only allowed to drive 90KPH, For that U lost: %i bucks",vehspeed,vehspeed*2);
                SendClientMessage(playerid,COLOR_RED, speed_string);
                GameTextForPlayer(playerid,"~r~B~y~U~b~S~g~T~w~E~p~D",5000,3);
               
                //Dialog om te betalen
                format(speed_string2,300,"{FFFFFF}U must pay: ${FF6347}%i{FFFFFF}\nBecause You were Driving {FF6347}%i{FFFFFF}Faster than allowed!\n\nIf you don't pay, U will becoma a suspect!",final_speed_int*2,final_speed_int-90);
                ShowPlayerDialog(playerid,DIALOG_PAYME,DIALOG_STYLE_MSGBOX,"Speed Cam",speed_string2,"Pay","Fuck off!");
               
                camflash(playerid);
                SetTimerEx("resflashed",3000,false,"i",playerid);
                IsFlashed[playerid] = 1;
            }
        }
    }
and

pawn Код:
//==============================================================================
//Pay ticket when flashed
//==============================================================================
    if(dialogid == DIALOG_PAYME)
    {
        if(!response)
        {
            //Will make that later
        }
        else
        {
            //here I need the pay ticket stuff
        }
    }
well, how can I use the amount of money used under OnPlayerUpdate, and use it in my OnDialogResponse?
I need the finalspeed_int*2 amount, to be able to use anywhere in my GM :/
Reply
#6

Define the variable at the top of your script.
Reply
#7

umm, how should it look like? the define.
Reply
#8

When I do this:
pawn Код:
#define TICKET finalspeed_int*2
pawn Код:
if(dialogid == DIALOG_PAYME)
    {
        if(!response)
        {
            new name[MAX_PLAYER_NAME], string[128];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s(%d) has ignored their ticket for driving to fast. Get that idiot!",name,playerid);
            SendClientMessageToAllCops(string);
            SendClientMessage(playerid,COLOR_ORANGE,"You have ignored your ticket, and your wanted level has increased by 2!");
           
            SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
        }
        else
        {
            GivePlayerMoney(playerid, -TICKET);
        }
    }
it says, undefined symbol, finalspeed_init
Reply
#9

change finalspeed_int to global.
pawn Код:
new finalspeed_int[MAX_PLAYERS];
Reply
#10

Ahh, so I must make a variable and use it like this: giveplayermoney(playerid,finalspeed_int*2)?

EDIT:
pawn Код:
if(dialogid == DIALOG_PAYME)
    {
        if(!response)
        {
            new name[MAX_PLAYER_NAME], string[128];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "%s(%d) has ignored their ticket for driving to fast. Get that idiot!",name,playerid);
            SendClientMessageToAllCops(string);
            SendClientMessage(playerid,COLOR_ORANGE,"You have ignored your ticket, and your wanted level has increased by 2!");
           
            SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
        }
        else
        {
            SendClientMessage(playerid,COLOR_SEXYGREEN,"You have paid your ticket!");
            GivePlayerMoney(playerid,finalspeed_int[playerid]*2);
        }
    }
I get the message, but the money doesn't change :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)