SA-MP Forums Archive
HELP every 5 seconds star when driving in left side - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: HELP every 5 seconds star when driving in left side (/showthread.php?tid=653837)



HELP every 5 seconds star when driving in left side - Shadow0707 - 14.05.2018

I need help everytime player drives on the left side of the road there should be a gametext that'll show the player that he's driving in the left side and I want the player to get 1 star every 5 seconds on driving in the left side

i've tried it but i failed. (I'm new in scripting sorry)

Код:
forward OnPlayerGhostDriving(playerid, zone, Float:X, Float:Y, Float:Z, Float:A);
public OnPlayerGhostDriving(playerid, zone, Float:X, Float:Y, Float:Z, Float:A)
{
    //Example:
    GameTextForPlayer(playerid, "~r~Drive in the right side of the road !", 1000, 4);
    // Start a 5 second timer to end the Timer
    SetTimerEx("EndTimer", 5000, false, "i", playerid);
    return 1;
}

forward OnPlayerDrivingOnTrainTrack(playerid, zone, Float:X, Float:Y, Float:Z);
public OnPlayerDrivingOnTrainTrack(playerid, zone, Float:X, Float:Y, Float:Z)
{
    //example:
    GameTextForPlayer(playerid, "~r~Do not drive on~n~the train tracks!", 1000, 4);
    SetTimerEx("EndTimer1", 5000, false, "i", playerid);
    return 1;
}
// The timer function - the code to be executed when the timer is called goes here
forward EndTimer(playerid);
public EndTimer(playerid)
{
    if ( GetPlayerWantedLevel(playerid) > 0 ) // If player has 1 or more stars
    {
        GameTextForPlayer(playerid, "~r~Do not drive on~n~the train tracks!", 1000, 4);
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
    }
}
forward EndTimer1(playerid);
// The timer function - the code to be executed when the timer is called goes here
public EndTimer1(playerid)
{
    // Let's notify them also
    GameTextForPlayer(playerid, "~r~Do not drive on~n~the train tracks!", 1000, 4);
    SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
    return 1;
}



Re: HELP every 5 seconds star when driving in left side - Sew_Sumi - 14.05.2018

This is something that only full high end scripters would attempt really, I'd suggest you start off with something a lot simpler.

What'd you get up to as such? and what were you using?

I notice no usage of the streamer functions, nor natives in checking their real locations.


Re: HELP every 5 seconds star when driving in left side - Shadow0707 - 14.05.2018

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
This is something that only full high end scripters would attempt really, I'd suggest you start off with something a lot simpler.

What'd you get up to as such? and what were you using?

I notice no usage of the streamer functions, nor natives in checking their real locations.
I'm using Keep your lane (https://sampforum.blast.hk/showthread.php?tid=550986

and he gave this code

Код:
forward OnPlayerGhostDriving(playerid, zone, Float:X, Float:Y, Float:Z, Float:A);
public OnPlayerGhostDriving(playerid, zone, Float:X, Float:Y, Float:Z, Float:A)
{
    //Example:
    GameTextForPlayer(playerid, "~r~Wrong lane!", 1000, 4);
    return 1;
}

forward OnPlayerDrivingOnTrainTrack(playerid, zone, Float:X, Float:Y, Float:Z);
public OnPlayerDrivingOnTrainTrack(playerid, zone, Float:X, Float:Y, Float:Z)
{
    //example:
    GameTextForPlayer(playerid, "~r~Do not drive on~n~the train tracks!", 1000, 4);
    return 1;
}
And i want when player drive in left side of the road the 5 seconds timer start and after the timer's done he'll get 1 star.


Re: HELP every 5 seconds star when driving in left side - Shadow0707 - 15.05.2018

anyone? Sry.


Re: HELP every 5 seconds star when driving in left side - ISmokezU - 15.05.2018

I agree with Sew.

What you are looking for is called nodes. Since there isn't a released code from the thread below (also Gamer_Z removed all his threads and left). This would be extremely hard for someone who doesn't know how, to begin with.

On the bright side, NaS has the lastest nodes possible, could get them from him and play around with it a bit.

https://sampforum.blast.hk/showthread.php?tid=564533


Re: HELP every 5 seconds star when driving in left side - Shadow0707 - 15.05.2018

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
I agree with Sew.

What you are looking for is called nodes. Since there isn't a released code from the thread below (also Gamer_Z removed all his threads and left). This would be extremely hard for someone who doesn't know how, to begin with.?

On the bright side, NaS has the lastest nodes possible, could get them from him and play around with it a bit.

https://sampforum.blast.hk/showthread.php?tid=564533
Okay i'll try this and try to edit it a bit thanks i'll update after it.


Re: HELP every 5 seconds star when driving in left side - Sew_Sumi - 15.05.2018

I looked over this last night, there is a function to check if the player is in the zone, but it's quite complicated.


What you will need is a tick timer, and simply have it count up on a variable hooked to the player (Will be an array) and simply count up if continuing to drive on the wrong side of the road. Once it hits 5, it'll then have to add the star.

You can then ignore that player by checking in that star giving check, whether they have a wanted level.

Making a 5 second timer attached to the player will make them wanted, or looked at, even if they started driving properly.


That include, is actually quite impressive,as well as the other releases that have covered this.


Re: HELP every 5 seconds star when driving in left side - Shadow0707 - 16.05.2018

I've removed it cuz it's bugging my script and I have a new problem with textdraws i don't know much with textdraws



here's the code

The line at the top

Код:
Convoys_Init()
{
	for (new i; i < MAX_CONVOYS; i++)
	{
		AConvoys[i][ConvoyTextLeader] = TextDrawCreate(320.0, 1.0, " "); // Create the textdraw for the leader
		TextDrawSetShadow(AConvoys[i][ConvoyTextLeader], 1); // Reduce the shadow to 1
		TextDrawAlignment(AConvoys[i][ConvoyTextLeader], 2); // Align the convoy-infobar to the center for the leader
		TextDrawUseBox(AConvoys[i][ConvoyTextLeader], 1); // Set the missiontext to display inside a box
		TextDrawBoxColor(AConvoys[i][ConvoyTextLeader] ,0x00000066); // Set the box color of the missiontext
		TextDrawLetterSize(AConvoys[i][ConvoyTextLeader], 0.3, 0.8); // Set Letter Size
		TextDrawFont(AConvoys[i][ConvoyTextLeader], 2); // Set the font

		AConvoys[i][ConvoyTextMember] = TextDrawCreate(320.0, 1.0, " "); // Create the textdraw for the members
		TextDrawSetShadow(AConvoys[i][ConvoyTextLeader], 1); // Reduce the shadow to 1
		TextDrawAlignment(AConvoys[i][ConvoyTextMember], 2); // Align the convoy-infobar to the center for the members
		TextDrawUseBox(AConvoys[i][ConvoyTextMember], 1); // Set the missiontext to display inside a box
		TextDrawBoxColor(AConvoys[i][ConvoyTextMember] ,0x00000066); // Set the box color of the missiontext
		TextDrawLetterSize(AConvoys[i][ConvoyTextMember], 0.3, 0.8); // Set Letter Size
		TextDrawFont(AConvoys[i][ConvoyTextMember], 2); // Set the font
	}
}
The 2 lines below is speedometere
Код:
    Speedometer_Setup(playerid)
    {
            // Setup the speedometer for the player
            APlayerData[playerid][SpeedometerText] = TextDrawCreate(500.0, 389.0, " ");
            TextDrawFont(APlayerData[playerid][SpeedometerText], 2);
            TextDrawLetterSize(APlayerData[playerid][SpeedometerText], 0.350000, 1.500000);
            TextDrawColor(APlayerData[playerid][SpeedometerText], -1);
            TextDrawSetShadow(APlayerData[playerid][SpeedometerText], 0);
            TextDrawUseBox(APlayerData[playerid][SpeedometerText], 1);
            TextDrawBoxColor(APlayerData[playerid][SpeedometerText], 0x00000066);
            APlayerData[playerid][FuelGauge] = TextDrawCreate(500.0, 409.0, " ");
            TextDrawFont(APlayerData[playerid][FuelGauge], 2);
            TextDrawLetterSize(APlayerData[playerid][FuelGauge], 0.350000, 1.500000);
            TextDrawColor(APlayerData[playerid][FuelGauge], -1);
            TextDrawSetShadow(APlayerData[playerid][FuelGauge], 0);
            TextDrawUseBox(APlayerData[playerid][FuelGauge], 1);
            TextDrawBoxColor(APlayerData[playerid][FuelGauge], 0x00000066);
            // Enable the TextDraw for this player
            TextDrawShowForPlayer(playerid, APlayerData[playerid][SpeedometerText]);
            TextDrawShowForPlayer(playerid, APlayerData[playerid][FuelGauge]);

            // Start the speedometer timer
            APlayerData[playerid][SpeedometerTimer] = SetTimerEx("Speedometer_Update", 100, true, "i", playerid);

            return 1;
    }



Re: HELP every 5 seconds star when driving in left side - Sew_Sumi - 16.05.2018

With textdraws, it's 640x480 is the size of the screen, so you want to look for a TextDrawCreate that is made up in the top left at 0,0, and the other bottom right ones will be near 600x440 or something.


You'll just have to find them, as they're likely to be linked to something else and because that isn't working, or that it's been editted wrong, it'll stop it from being taken off the screen.


Re: HELP every 5 seconds star when driving in left side - Shadow0707 - 16.05.2018

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
With textdraws, it's 640x480 is the size of the screen, so you want to look for a TextDrawCreate that is made up in the top left at 0,0, and the other bottom right ones will be near 600x440 or something.


You'll just have to find them, as they're likely to be linked to something else and because that isn't working, or that it's been editted wrong, it'll stop it from being taken off the screen.
Is it possible to put 2 textdraws in 1 box only ? show me a sample code.