Createvehicle problem
#1

Hi, so for some reason I can't create any vehicle using CreateVehicle, it just doesn't show up in game, the model id is valid and I don't have any vehicle in my server so I didn't reach the l;imit...

Example : CreateVehicle(520, 182.3132,-193.0358,1.4343,189.8180, -1,-1, 60);

Under OnGameModeInit, like it should be and yeah it doesn't create the vehicle in game, any idea why ?
Reply
#2

Look for DestroyVehicle in the script, maybe you destroyed it somewhere
Reply
#3

None of that, anything else ?
Reply
#4

Quote:
Originally Posted by vernz
Посмотреть сообщение
Hi, so for some reason I can't create any vehicle using CreateVehicle, it just doesn't show up in game, the model id is valid and I don't have any vehicle in my server so I didn't reach the l;imit...

Example : CreateVehicle(520, 182.3132,-193.0358,1.4343,189.8180, -1,-1, 60);

Under OnGameModeInit, like it should be and yeah it doesn't create the vehicle in game, any idea why ?
Hm.. I think CreateVehicle is the wrong way to do that.
Try to use
PHP код:
AddStaticVehicle(modelidxyzanglecolor1color2
Example:
PHP код:
AddStaticVehicle(411,- 1989.0293271.090534.902786.9787, -1, -1); // Infernus - Wang Car - SF - Spawning with randoms colors 
And if you want to create a spawning command, CreateVehicle is a good thing.

Example :
PHP код:
CMD:v(playeridparams[])
{
    new 
Float:xFloat:yFloat:zFloat:AnglevehIDstring[150];
    if(
GetPlayerInterior(playerid) > 0) return SendClientMessage(playeridred"[SYSTEM] "rougeUC"You are in an interior !"); // If the player is in an interior, return an error message
    
if(GetPlayerVirtualWorld(playerid)> 0)return SendClientMessage(playeridred"[SYSTEM] "rougeUC"You cannot spawn vehcle in this virtualworld."); // If the player is in an virtual world other than the default virtual world (world 0), return an error message
    
if(sscanf(params,"i"vehID)) return SendClientMessage(playeridX11_LIGHT_BLUE_1"/v [vehicle_id] [400-611]"); // If the player type /v without parameter
    
if(611<vehID || vehID<400) return SendClientMessage(playeridredrougeUF"[SYSTEM] "rougeUC"Invalid ID! [400-611]"); // If the ID typed is behind 400 or upper than 611
    
if(IsPlayerInAnyVehicle(playerid)) { RemovePlayerFromVehicle(playerid); } // Remove player if he is already in an vehicle
    
GetPlayerPos(playeridxyz);
     
GetPlayerFacingAngle(playeridAngle); // Stocking different values for spawning the vehicle
    
vehID CreateVehicle(vehIDxyzAngle, -1, -1600); // Spawning the vehicle at the player's coordinates - Stocking the vehicle's ID in vehID
    
PutPlayerInVehicle(playeridvehID0); // Put the player in the vehicle as the driver
    
format(stringsizeof(string), "Vehicle Spawned ! (ID : %i)"GetVehicleModel(vehID)); // Send a message with model of the vehicle (not the ID)
    
SendClientMessage(playeridmarroncstring);
    return 
1;

NB: I tried to translate this command in English. Please, don't care about orthography mistakes.
Reply
#5

that's the problem, I also tried with a command to spawn a vehicle with /veh, doesn't work, first time it's happening in 6 years lol never had problem with that
Reply
#6

What happening when you put your command? Nothing appears ?
Show the lines in GameModeInit()
Show also OnVehicleSpawn(vehicleid)! I don't really understand why it's not working.. :/
Reply
#7

Can you send your OnGameModeInit if you please? will make it easier for us.
Reply
#8

PHP код:
public OnGameModeInit()
{
    
//==========================================================================
    //      -- > Loads
    //==========================================================================
    
mysql mysql_connect(SQL_HOSTSQL_USERSQL_DBSQL_PASS);
    
mysql_log(LOG_ALL);
    if(
mysql_errno(mysql) == 0)
    {
        
mysql_log(LOG_ERROR LOG_WARNING LOG_DEBUG);
        
printf("------------------------------------------------------------------------------");
        
printf("[MYSQL]: Connection to `%s`@'%s' succesful!"SQL_DBSQL_HOST);
        
printf("------------------------------------------------------------------------------");
    }
    else
    {
        
printf("------------------------------------------------------------------------------");
        
printf("[MYSQL]: ERROR: Connection to `%s`@'%s' failed!"SQL_DBSQL_HOST);
        
printf("------------------------------------------------------------------------------");
    }
    
    
mysql_tquery(mysql"SELECT * FROM `Icons` ORDER BY SQLID ASC""LoadIcons");
    
//mysql_tquery(mysql, "SELECT * FROM `vehicles`", "Car_Load", "");
    
CreateVehicle(520182.3132,-193.0358,1.4343,189.8180, -1,-160); // bike 1
    
    
DisableInteriorEnterExits();
    
DisableNameTagLOS();
    
ShowPlayerMarkers(PLAYER_MARKERS_MODE_OFF);
    
EnableStuntBonusForAll(0);
    
ShowNameTags(0);
    
    for(new 
0MAX_PLAYERSi++)
    {
        
InfoBox[i] = TextDrawCreate(323.000030363.377899"Testing");
        
TextDrawLetterSize(InfoBox[i], 0.3090001.417481);
        
TextDrawTextSize(InfoBox[i], -114.333312300.325866);
        
TextDrawAlignment(InfoBox[i], 2);
        
TextDrawColor(InfoBox[i], -1);
        
TextDrawUseBox(InfoBox[i], true);
        
TextDrawBoxColor(InfoBox[i], 51);
        
TextDrawSetShadow(InfoBox[i], 0);
        
TextDrawSetOutline(InfoBox[i], -1);
        
TextDrawBackgroundColor(InfoBox[i], 255);
        
TextDrawFont(InfoBox[i], 1);
        
TextDrawSetProportional(InfoBox[i], 1);
    }
    
    return 
1;

Reply
#9

FIXED

I wasn't even in the virtualworld 0 for some reason... oh well Thanks for the help 1 +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)