SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/09/2019, 12:32 PM   #1
BigGreen
Big Clucker
 
Join Date: Feb 2015
Posts: 86
Reputation: 8
Default [HELP] PaynSpray

Hi so i've been trying to figure out how i can get /enterpns to work in multiple locations like for example Fort Carson when the player uses /enterpns at Fort carson it would place them into the said garage and when the repair timer is up it would send them back to the location they previously used the command or if i was to use the command at a garage in Dillimore it would place the player with their vehicle into the dillimore garage then infront of the dillimore PnS when the timer is up


Code:
CMD:enterpns(playerid,vehicleid, params[])
{
    if(!IsPlayerInRangeOfPoint(playerid,5.0,312.6309,-65.7935,1.3251) && !IsPlayerInRangeOfPoint(playerid,5.0,2241.7361,30.7780,26.5088) && !IsPlayerInRangeOfPoint(playerid,5.0,-98.7972,1107.3752,19.5593) && !IsPlayerInRangeOfPoint(playerid,5.0,1085.25,-1381.94,13.52)) return SendClientMessage(playerid,COLOR_RED,"You're not at the right place");
    GiveMoney(playerid, -500);
    if(!IsPlayerInAnyVehicle(playerid))
		return SendClientMessage(playerid, -1, "ERROR: You can't do this unless you're in a vehicle.");

	{
      if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
      {
        SetVehiclePos(GetPlayerVehicleID(playerid), 710.9271,-454.5685,-0.7131) && SetVehiclePos(GetPlayerVehicleID(playerid), 710.9271,-454.5685,-0.7131);
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_GREY, "Please wait while we repair your vehicle...");
		TogglePlayerControllable(playerid,0);
        SetTimerEx("PaynSpray", 5000, false, "i", playerid);
      }
      else
      {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be the driver!");
      }
    }
    return 1;
}

forward PaynSpray(playerid);
public PaynSpray(playerid)
{
 SetVehiclePos(GetPlayerVehicleID(playerid), 312.6309,-65.7935,1.3251) && SetVehiclePos(GetPlayerVehicleID(playerid), 2241.7361,30.7780,26.5088);
 TogglePlayerControllable(playerid,1);
 return 1;
}
Someone please tell me what i'm doing wrong and try to help fix it
__________________
BigGreen is offline   Reply With Quote
Old 14/09/2019, 12:43 PM   #2
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: [HELP] PaynSpray

Why are you using && on SetVehiclePos? It can't work this way
I've edited your code a bit, i hope it's what you needed:
Code:
CMD:enterpns(playerid,vehicleid, params[])
{
    if(!IsPlayerInRangeOfPoint(playerid,5.0,312.6309,-65.7935,1.3251) && !IsPlayerInRangeOfPoint(playerid,5.0,2241.7361,30.7780,26.5088) && !IsPlayerInRangeOfPoint(playerid,5.0,-98.7972,1107.3752,19.5593) && !IsPlayerInRangeOfPoint(playerid,5.0,1085.25,-1381.94,13.52)) return SendClientMessage(playerid,COLOR_RED,"You're not at the right place");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "ERROR: You can't do this unless you're in a vehicle.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be the driver!");
    GiveMoney(playerid, -500);
    new Float:x,Float:y,Float:z,Float:a;
    GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z); //Getting XYZ pos before entering the PnS
    GetVehicleZAngle(GetPlayerVehicleID(playerid),a); //Getting the angle before entering the PnS
    SetPVarFloat(playerid,"PnSxpos",x); //Setting X to a PVarFloat so we can use it later
    SetPVarFloat(playerid,"PnSypos",y); //Setting Y to a PVarFloat so we can use it later
    SetPVarFloat(playerid,"PnSzpos",z); //Setting Z to a PVarFloat so we can use it later
    SetPVarFloat(playerid,"PnSapos",a); //Setting angle to a PVarFloat so we can use it later
    SetVehiclePos(GetPlayerVehicleID(playerid), 710.9271,-454.5685,-0.7131); //Entering to PnS
    RepairVehicle(GetPlayerVehicleID(playerid)); //If it's a default PnS this wouldn't be needed since it repairs by default
    SendClientMessage(playerid, COLOR_GREY, "Please wait while we repair your vehicle...");
    TogglePlayerControllable(playerid,0);
    SetTimerEx("PaynSpray", 5000, false, "i", playerid);
    return 1;
}

forward PaynSpray(playerid);
public PaynSpray(playerid)
{
 SetVehiclePos(GetPlayerVehicleID(playerid), GetPVarFloat(playerid,"PnSxpos"),GetPVarFloat(playerid,"PnSypos"),GetPVarFloat(playerid,"PnSzpos")); //Setting the vehicle back to its position before entering the PnS
 SetVehicleZAngle(GetPlayerVehicleID(playerid),GetPVarFloat(playerid,"PnSapos")); //Setting the vehicle back to its angle before entering the PnS
 TogglePlayerControllable(playerid,1);
 return 1;
}
__________________
Jonny is offline   Reply With Quote
Old 14/09/2019, 12:51 PM   #3
BigGreen
Big Clucker
 
Join Date: Feb 2015
Posts: 86
Reputation: 8
Default Re: [HELP] PaynSpray

I've tried without it but i still get the same problem
__________________
BigGreen is offline   Reply With Quote
Old 14/09/2019, 12:52 PM   #4
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: [HELP] PaynSpray

Quote:
Originally Posted by BigGreen View Post
I've tried without it but i still get the same problem
I edited my second post, see if that's what you needed
Also, you didn't explained the problem, what's not working?
__________________
Jonny is offline   Reply With Quote
Old 14/09/2019, 01:08 PM   #5
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 27
Default Re: [HELP] PaynSpray

Well, I won't do the work for you, but I can give you some tips.
This might be useful:
Code:
new Float:paynsprayLocations[][3] = {
  {1024.883544,-1024.313232,32.101562},//LS near cementary
  {2064.169189,-1831.570434,13.546873},//LS near groove
  {487.065704,-1740.584350,11.127986},// LS beach
  {720.157592,-455.741790,16.335937},//LS Dillimore
  {-1904.448608,284.930389,41.046875},//SF Doherty
  {-2425.696533,1022.731689,50.397659},//SF north
  {1977.534790,2162.374023,11.070309},//LV north
  {2394.064941,1488.491088,10.827350},//LV east near strip
  {-99.950195,1118.861328,19.741704},//LV outside west
  {-1420.896972,2584.359130,55.843261}//LV outside northwest
};
- loop through the array and check distance (Or do you want the command to only work in specific locations?)
Code:
for(new i;i<sizeof(paynsprayLocations);i++)
{
   if(GetPlayerDistanceFromPoint(playerid,paynsprayLocations[i][0],...)< 100.0)
   {
       //set position etc.
   }
}
- save current position in a global array or pass the position to the timer
Code:
//inside command
GetVehiclePos(...);
SetTimerEX("PaynSpray",5000,false,"ifff",playerid,x,y,z);

//callback:
PaynSpray(playerid,Float:x,Float:y,Float:z)
{
   SetVehiclePos(...,x,y,z);
}
Plastikmensch is offline   Reply With Quote
Old 14/09/2019, 01:22 PM   #6
BigGreen
Big Clucker
 
Join Date: Feb 2015
Posts: 86
Reputation: 8
Default Re: [HELP] PaynSpray

Quote:
Originally Posted by darkdrago View Post
I edited my second post, see if that's what you needed
Also, you didn't explained the problem, what's not working?
It works just the way i needed it to thanks

and the problem i had was when i used /enterpns at a repair shop in another location it teleports the vehicle across the map to another garage instead of the one i was previously at
__________________
BigGreen is offline   Reply With Quote
Old 14/09/2019, 02:27 PM   #7
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 280
Reputation: 38
Default Re: [HELP] PaynSpray

Quote:
Originally Posted by BigGreen View Post
It works just the way i needed it to thanks

and the problem i had was when i used /enterpns at a repair shop in another location it teleports the vehicle across the map to another garage instead of the one i was previously at
It was because you weren't saving your previous coordinates before entering the PnS, also consider Plastikmensch's post if you wanna do it for every PnS, the array she posted has every Pay 'n Spray from the game
__________________
Jonny is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfender/PayNSpray server-sided money. Dizzle Scripting Help 6 10/07/2015 08:13 PM
Detect paynspray Face9000 Scripting Help 3 13/01/2012 09:23 PM
Can you give me Paynspray script? James_Bourne Help Archive 10 06/08/2011 07:21 PM


All times are GMT. The time now is 02:40 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.