PDA

View Full Version : Need help with PNS command!


Hade.
28/02/2013, 07:04 PM
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;
}

Basssiiie
28/02/2013, 09:36 PM
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).

Hade.
01/03/2013, 10:07 AM
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.

Hade.
01/03/2013, 02:06 PM
Anyone?

Basssiiie
01/03/2013, 02:40 PM
Have you tried debugging it with print and printf etc?

Mmartin
01/03/2013, 02:46 PM
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.

Hade.
01/03/2013, 03:05 PM
yea, i saw that mistake and fixed it, il try again,

Hade.
01/03/2013, 03:26 PM
got it fixed, removed that and added a few things.