SA-MP Forums Archive
Quick help please - 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: Quick help please (/showthread.php?tid=312776)



Quick help please - Luis- - 22.01.2012

Hi, i'm planning to make something that flings your car forward when it's a range of the point. here is my code.
pawn Код:
forward PipeCheck(playerid);
public PipeCheck(playerid)
{
    SendClientMessageToAll(COLOR_WHITE, "DEBUG: Pipecheck started");
    if(IsPlayerInRangeOfPoint(playerid, 2.5, 1976.7637,-2522.4316,18.6932))
    {
        new Float:vx, Float:vy, Float:vz;
        GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);

        new Float:va;
        GetVehicleZAngle(GetPlayerVehicleID(playerid), va);

        SetVehicleVelocity(GetPlayerVehicleID(playerid), floatsin(-va, degrees) * 0.9, floatcos(va, degrees) * 2.9 , vz);
        SendClientMessageToAll(COLOR_WHITE, "DEBUG: Player has been flunged forward!");
    }
    return 1;
}
It sends the first text but doesn't' sent the second one.


Re: Quick help please - 2KY - 22.01.2012

Have you double-checked your coordinates? Also, how many MS is the timer being set for?


Re: Quick help please - Luis- - 22.01.2012

400 seconds. My coords are correct.


Re: Quick help please - 2KY - 22.01.2012

You may wish to put the timer at a lower milliseconds (higher speed). As it works with velocity, you can't stop at the coordinates - you would have to continue moving. It's getting stuck on your coordinate check, though.. which is very odd.


Re: Quick help please - Luis- - 22.01.2012

Still nothing, just set it to 100.


Re: Quick help please - 2KY - 22.01.2012

That's odd. Try adding a message AFTER the player position check to see if it's really getting stuck on that;

pawn Код:
forward PipeCheck(playerid);
public PipeCheck(playerid)
{
    SendClientMessageToAll(COLOR_WHITE, "DEBUG: Pipecheck started");
    if(IsPlayerInRangeOfPoint(playerid, 2.5, 1976.7637,-2522.4316,18.6932))
    {
        SendClientMessageToAll(COLOR_WHITE, "DEBUG: Passed the Player Coordinate check!");
        new Float:vx, Float:vy, Float:vz;
        GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
        SendClientMessageToAll(COLOR_WHITE, "DEBUG: Got their velocity!");

        new Float:va;
        GetVehicleZAngle(GetPlayerVehicleID(playerid), va);
        SendClientMessageToAll(COLOR_WHITE, "DEBUG: Got their angle!");

        SetVehicleVelocity(GetPlayerVehicleID(playerid), floatsin(-va, degrees) * 0.9, floatcos(va, degrees) * 2.9 , vz);
        SendClientMessageToAll(COLOR_WHITE, "DEBUG: Player has been flunged forward!");
    }
    return 1;
}



Re: Quick help please - Luis- - 22.01.2012

It seems to keep saying "Pipecheck started"


Re: Quick help please - 2KY - 22.01.2012

At least that narrowed down the problem some, which I already had a hunch was the problem, anyway. I'm really not sure, have you ever done a system like this before? Do you need a pickup or something in that position for it to work?


Re: Quick help please - Luis- - 22.01.2012

I haven't done anything like this before, i'll give it ago though.


Re: Quick help please - 2KY - 22.01.2012

Try the pickup idea, that is pickupable in a vehicle, and put all of that code into OnPlayerPickupPickup rather than a timer. May work better for you.