park cmd problem
#1

hello,
I am making park command, and the problem I can type /park in any vehicle ( i want it only to his car ) also it destroys the vehicle and it dosen't spawn again


Here is my park command:


PHP код:
CMD:park(playeridparams[])
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
playername[MAX_PLAYER_NAME];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    
GetPlayerName(playeridplayernamesizeof(playername));
    if(!
strcmp(VehicleInfo[vehicleid][vehOwner], playernamefalse) && !IsPlayerInVehicle(playeridvehicleid)) return SendClientMessage(playeridCOLOR_GREY"You are not in your vehicle.");
    {
       new 
Float:parkvehXFloat:parkvehYFloat:parkvehZ;
       
GetVehiclePos(vehicleidparkvehXparkvehYparkvehZ);
       
VehicleInfo[vehicleid][vehX] = parkvehX;
       
VehicleInfo[vehicleid][vehY] = parkvehY;
       
VehicleInfo[vehicleid][vehZ] = parkvehZ;
       
DestroyVehicle(vehicleid);
       
VehicleInfo[newvehicle][vehicle] = CreateVehicle(VehicleInfo[vehicleid][vehModel], VehicleInfo[vehicleid][vehX], VehicleInfo[vehicleid][vehY], VehicleInfo[vehicleid][vehZ], 0, -1, -1, -1);
       return 
1;
       }
 } 
Reply
#2

Hello!

Try this in the following way:
PHP код:
CMD:park(playerid,params[])
{
    new 
vehicleid GetPlayerVehicleID(playerid),playername[MAX_PLAYER_NAME],Float:parkvehCoord[3];
    if(!
IsPlayerLoggedIn(playerid))return SendClientMessage(playerid,COLOR_GREY,"You need to login first before using any command.");
    
GetPlayerName(playerid,playername,sizeof playername);
    if(
strcmp(VehicleInfo[vehicleid][vehOwner],playername,false) || !IsPlayerInVehicle(playerid,vehicleid))return SendClientMessage(playerid,COLOR_GREY,"You aren't in your vehicle.");
    
GetVehiclePos(vehicleid,parkvehCoord[0],parkvehCoord[1],parkvehCoord[2]);
    
VehicleInfo[vehicleid][vehX] = parkvehCoord[0];
    
VehicleInfo[vehicleid][vehY] = parkvehCoord[1];
    
VehicleInfo[vehicleid][vehZ] = parkvehCoord[2];
    
SetVehicleToRespawn(vehicleid);
    return 
1;

Mencent
Reply
#3

it dosen't spawn in new postion, also i can use park command even in other vehicles...
EDIT: I mean i can use this command in all ownedable vehicles not especialy my car
Reply
#4

Then show your vehicle buying codes
Reply
#5

PHP код:
    else if(dialogid == 11// Bikes
    
{
        new 
string[128], caridprice;
        if(
response)
        {
            switch(
listitem)
            {
                case 
0: {carid 481price 20000;} // BMX
                
case 1: {carid 462price 35000;} // FAGGIO
                
case 2: {carid 463price 60000;} // FREEWAY
                
case 3: {carid 468price 70000;} // SANCHEZ
                
case 4: {carid 471price 20000;} // QUAD
                
case 5: {carid 461price 100000;} // PCJ-600
                
case 6: {carid 521price 150000;} // FCR-900
                
case 7: {carid 522price 250000;}
            }
            if(
price PlayerInfo[playerid][pMoney]) return SendClientMessage(playeridCOLOR_GREY"You don't have enough money on you.");
            
GiveZaiatMoney(playerid, -price);
         
//    format(string, sizeof(string), " You have purchased a %s. (Unlock it using /lock)", RVN(carid));
           // SendClientMessage(playerid, COLOR_GREEN, string);
            
new playername[MAX_PLAYER_NAME], Float:Pos[3];
            
format(stringsizeof(string), "/vehicles/%d.ini"newvehicle);
            new 
INI:File=INI_Open(string);
            
GetPlayerName(playeridplayernamesizeof(playername));
            
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
            
INI_WriteInt(File"Model"carid);
            
INI_WriteString(File"Owner"playername);
            
INI_WriteFloat(File"PosX"Pos[0]);
            
INI_WriteFloat(File"PosY"Pos[1]);
            
INI_WriteFloat(File"PosZ"Pos[2]);
            
INI_Close(File);
            
VehicleInfo[newvehicle][vehicle]=CreateVehicle(carid532.3726,-1287.4926,17.2422,272.3125,0,0,32000);
            }
        
newvehicle++;

Reply
#6

bump
Reply
#7

Quote:
Originally Posted by Rabea
Посмотреть сообщение
bump
The problem is that after you buy, you don't tell it's car variables the current data.

So, do this for the rest.

Look:
pawn Код:
case 4: {carid = 471; price = 20000;} // QUAD
                case 5: {carid = 461; price = 100000;} // PCJ-600
                case 6: {carid = 521; price = 150000;} // FCR-900
                case 7: {carid = 522; price = 250000;}
            }
            if(price > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
            GiveZaiatMoney(playerid, -price);
         //    format(string, sizeof(string), " You have purchased a %s. (Unlock it using /lock)", RVN(carid));
           // SendClientMessage(playerid, COLOR_GREEN, string);
            new playername[MAX_PLAYER_NAME], Float:Pos[3];
            format(string, sizeof(string), "/vehicles/%d.ini", newvehicle);
            new INI:File=INI_Open(string);
            GetPlayerName(playerid, playername, sizeof(playername));
            GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
            INI_WriteInt(File, "Model", carid);
            INI_WriteString(File, "Owner", playername);
            INI_WriteFloat(File, "PosX", Pos[0]);
            INI_WriteFloat(File, "PosY", Pos[1]);
            INI_WriteFloat(File, "PosZ", Pos[2]);
            INI_Close(File);
            VehicleInfo[newvehicle][vehicle]=CreateVehicle(carid, 532.3726,-1287.4926,17.2422,272.3125,0,0,32000);
           
            ---> VehicleInfo[newvehicle][vehX] = Pos[0];
            ---> VehicleInfo[newvehicle][vehY] = Pos[1];
            ---> VehicleInfo[newvehicle][vehZ] = Pos[2];

             // .........
            }
        newvehicle++;
}
Reply
#8

The reason you can use park commands in other vehicles is if the owner name is empty which you are not checking for.
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
The reason you can use park commands in other vehicles is if the owner name is empty which you are not checking for.
How i can do it?
Reply
#10

Quote:
Originally Posted by Rabea
Посмотреть сообщение
How i can do it?
Read my above post, I told about it...

And that's not just for name, it's for everything.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)