SA-MP Forums Archive
Car spawn at the wrong place? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car spawn at the wrong place? (/showthread.php?tid=142892)



Car spawn at the wrong place? - Jochemd - 20.04.2010

Hello,

I guess some people saw my carspawn topic before. Now I updated it and there is a weird error in it. I show you.
pawn Код:
case 5:
            {
              if(GetPlayerMoney(playerid) < 40000)
        return SendClientMessage(playerid,COLOR_RED,"--> You don't have $40000!")  && SetPlayerPos(playerid,-1979.8074,270.1521,35.1719) && TogglePlayerControllable(playerid,1);
        GivePlayerMoney(playerid,-40000);
        SetPlayerPos(playerid,-1979.8074,270.1521,35.1719);
        GetPlayerPos(playerid,x,y,z);
        PlayerPlaySound(playerid,1058,0,0,0);
        TogglePlayerControllable(playerid,1);
        CreateVehicle(402,x+2,y+2,z+2,0,0,0,0);
        return SendClientMessage(playerid, COLOR_YELLOW, "--> You bought a Buffalo!");
            }
The coцrdinates at SetPlayerPos are outside Wang Cars. I set GetPlayerPos so it gets the coordinates where the player is outside. Then the sound and freeze comes. Now the point: The car should spawn near GetPlayerPos. But it doesnt it spawns at my old coцrdinates! DOes someone know this bug? And how to fix it?

Regards, Jochem

BTW: I know I could use the same coцrds as SetPlayerPos. I dont want it; it needs to be simply to modify!



Re: Car spawn at the wrong place? - Jeffry - 20.04.2010

Try to use it UNDER PogglePlayerControllable.
Maybe it helps.


Re: Car spawn at the wrong place? - Jochemd - 20.04.2010

Nope Doesnt help


Re: Car spawn at the wrong place? - Jeffry - 20.04.2010

pawn Код:
if(GetPlayerMoney(playerid) < 40000) return SendClientMessage(playerid,COLOR_RED,"--> You don't have $40000!")  && SetPlayerPos(playerid,-1979.8074,270.1521,35.1719) && TogglePlayerControllable(playerid,1);
new car;
GivePlayerMoney(playerid,-40000);
car=CreateVehicle(402,-1979.8074,270.1521,35.1719,0,0,0,0);
PutPlayerInVehicle(playerid, car, 0);
PlayerPlaySound(playerid,1058,0,0,0);
TogglePlayerControllable(playerid,1);
return SendClientMessage(playerid, COLOR_YELLOW, "--> You bought a Buffalo!");
Tested and works.


Re: Car spawn at the wrong place? - DJDhan - 20.04.2010

there should be an else after an if maybe that's why it's not spawning in the new coordinates


Re: Car spawn at the wrong place? - FUNExtreme - 20.04.2010

Quote:
Originally Posted by DJDhan
there should be an else after an if maybe that's why it's not spawning in the new coordinates
WHAT!?


Re: Car spawn at the wrong place? - adsy - 20.04.2010

Quote:
Originally Posted by Jeffry
Try to use it UNDER PogglePlayerControllable.
Maybe it helps.
poggle lol


or you could simply use the teleport coords in variable form


Код:
x=-1979.8074,y=270.1521,z=35.1719;

SetPlayerPos(playerid, x,y,z);
PlayerPlaySound(playerid,1058,0,0,0);
TogglePlayerControllable(playerid,1);
CreateVehicle(402,x+2,y+2,z+2,0,0,0,0);
return SendClientMessage(playerid, COLOR_YELLOW, "--> You bought a Buffalo!");



Re: Car spawn at the wrong place? - DJDhan - 20.04.2010

Quote:
Originally Posted by FUNExtreme
Quote:
Originally Posted by DJDhan
there should be an else after an if maybe that's why it's not spawning in the new coordinates
WHAT!?
Well i didn't undertand why there was an "if player doesn't have $40000" to buy a car... but after that no "else if he has $40000" then give him the car an stuff. I just saw && and && after that ?


Re: Car spawn at the wrong place? - Hiddos - 20.04.2010

Before SetPlayerPos: new Float,Float:y,Float:z;

like
pawn Код:
case 5:
            {
              if(GetPlayerMoney(playerid) < 40000)
        return SendClientMessage(playerid,COLOR_RED,"--> You don't have $40000!")  && SetPlayerPos(playerid,-1979.8074,270.1521,35.1719) && TogglePlayerControllable(playerid,1);
        GivePlayerMoney(playerid,-40000);
        SetPlayerPos(playerid,-1979.8074,270.1521,35.1719);
        new Float:x,Float:y,Float:z; //That line. Else x,y,z are seen as values of zero (0)
        GetPlayerPos(playerid,x,y,z);
        PlayerPlaySound(playerid,1058,0,0,0);
        TogglePlayerControllable(playerid,1);
        CreateVehicle(402,x+2,y+2,z+2,0,0,0,0);
        return SendClientMessage(playerid, COLOR_YELLOW, "--> You bought a Buffalo!");
            }



Re: Car spawn at the wrong place? - Jochemd - 21.04.2010

Well, I don't really understand you, because when you see the script, I think everything is the right order ?