SA-MP Forums Archive
Need help with PNS command! - 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: Need help with PNS command! (/showthread.php?tid=419411)



Need help with PNS command! - Hade. - 28.02.2013

I need help with my pns command, i wanted to make the command that when a player is near the pay n spray and typer /paranda (/repair in english) then his vehicle teleports in to the PNS freezes for a time amount and then teleports out and takes his money, but when i try the command all the stuff like you arent near it and arent in a vehicle and no money works but the command itself doesnt do anything, no freezing no nothing. Really need help.

Command:

Код:
CMD:paranda(playerid, params[])
{
    new PlayerState = GetPlayerState(playerid);
    if(IsPlayerInRangeOfPoint(playerid, 7.0, 2075.6091,-1831.4385,13.5545))
    {
        if (PlayerState == PLAYER_STATE_PASSENGER || PlayerState == PLAYER_STATE_ONFOOT)
        {
		    SendClientMessage(playerid, COLOR_RED, "Sa ei saa parandusse siseneda jala/kхrvalistujana!");
		    return 1;
	    }
	    else if(PlayerState == PLAYER_STATE_DRIVER)
	    {
            if(GetPlayerMoney(playerid) <3500) return SendClientMessage(playerid,COLOR_RED, "Sul ei ole piisavalt raha masina parandamiseks! [3500 krooni]");
            if(IsPlayerInAnyVehicle(playerid))
            {
                SetVehiclePos(playerid, 2065.4656,-1831.3871,13.3786);
            }
            else
            {
                SetPlayerPos(playerid, 2065.4656,-1831.3871,13.3786);
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("PNSfreeze", 5000, false, "i", playerid);
                GivePlayerMoney(playerid,-3500);
                return 1;
            }
	    }
	}
	return 1;
}


forward PNSfreeze(playerid);
public PNSfreeze(playerid)
{
    TogglePlayerControllable(playerid, 1);
    SetVehiclePos(playerid, 2105.3506,-1775.3052,13.3918);
    return 1;
}



Re: Need help with PNS command! - Basssiiie - 28.02.2013

Try debugging your script with print and printf, it's likely that will help finding the cause. Also, note that 7.0 in IsPlayerInRangeOfPoint actually not that far is, it's only 7 meters. It's barely two vehicles away from the center of the Pay&Spray.

Also note that you're sending the playerid in the timer, but then you're using SetVehiclePos with the playerid? I can guess that that will move the incorrect vehicle (or move no vehicle at all).


Re: Need help with PNS command! - Hade. - 01.03.2013

Okay, but the 7 meters , it has to be like that, i have a pickup there that shows where you have to be. Still could someone do it, i didnt quite understand.


Re: Need help with PNS command! - Hade. - 01.03.2013

Anyone?


Re: Need help with PNS command! - Basssiiie - 01.03.2013

Have you tried debugging it with print and printf etc?


Re: Need help with PNS command! - Mmartin - 01.03.2013

The command makes zero sense. Especially this part:
Код:
if(IsPlayerInAnyVehicle(playerid))
            {
                SetVehiclePos(playerid, 2065.4656,-1831.3871,13.3786);
            }
            else
            {
                SetPlayerPos(playerid, 2065.4656,-1831.3871,13.3786);
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("PNSfreeze", 5000, false, "i", playerid);
                GivePlayerMoney(playerid,-3500);
                return 1;
            }
Do you even understand what the condition performs here? Why'd you move a player in the PNS if he's not in any vehicle? That's exactly what your condition does, moves the vehicle if the player is in any, if he's not, it moves him, freezes him and whatever else you wrote there. Fix that and it should work.


Re: Need help with PNS command! - Hade. - 01.03.2013

yea, i saw that mistake and fixed it, il try again,


Re: Need help with PNS command! - Hade. - 01.03.2013

got it fixed, removed that and added a few things.