Vehicles Random ID's
#1

Hey everybody, i make a comand /work to can work with one of for vehicle but i get an error
here is the CMD:
PHP код:
MD:work(playerid,params[])
{
    if(
IsPlayerConnected(playerid))
    {
        if (
GetPlayerState(playerid) == && PlayerToPoint(3.0playerid,2214.9500,2123.5903,10.8203))
        {
            if(
PlayerInfo[playerid][pJob] != 4) return SCM(playerid,COLOR_WHITE,"{FFF8C6}Tu nu esti Drugs Dealer.");
            
DisablePlayerCheckpoint(playerid);
            new 
                
Float:dx,Float:dy,Float:dz,Float:pos;
            
            
GetPlayerPos(playerid,dx,dy,dz);
            
GetPlayerFacingAngle(playerid,pos);
            new 
dCar CreateVehicle(dCarID[0][],dx,dy,dz,pos,-1,-1,-1);
            
PutPlayerInVehicle(playerid,dCar,0);
            
CP[playerid] = 12;
            
SetPlayerCheckpoint(playerid,0.0,0.0,0.0,3.0);
            
            
            
        }
    }
    return 
1;

And i want when a pleyer type /work to give one of this for vehicle's

PHP код:
new dCarID[4][] = {
{
440},
{
459},
{
482},
{
499}
}; 
And the error
PHP код:
New.pwn(37168) : error 029invalid expressionassumed zero 
Thank you
Reply
#2

I am not sure if you typed it here wrong, but start with "CMD:" not "MD:"
Reply
#3

I done, but now i have one more problem
He give me only car with id 440

i put like this
PHP код:
new dCar CreateVehicle(dCarID[0][0],dx,dy,dz,pos,-1,-1,-1); 
Reply
#4

Simple way to do that. Doesn't need enum.

PHP код:
new modelcar;
new 
Randveh random(4);
switch(
Randveh)
{
 Case 
0:
{
 
modelcar 440;
}
case 
1:
{
 
modelcar 459;
}
case 
2:
{
 
modelcar 482;
}
case 
3:
{
 
modelcar 499;
}
CreateVehicle(modelcar,dx,dy,dz,pos,-1,-1,-1);  

Reply
#5

This what you say i will make inside command ?
Reply
#6

pawn Код:
new dCarID[] = {440, 459, 482, 499};

new dCar = CreateVehicle(dCarID[random(sizeof(dCarID))], ... );
Reply
#7

i make it inside the command and now cont create the vehicle
Reply
#8

Thank you @jeff i give you one rep point
Thank's for all.
Reply
#9

@Jeff one more question, now if i want to destroy the vehicle when player exit the vehicle what i need to do ? i'm newbie sorry
Reply
#10

PHP код:
new dCar[MAX_PLAYERS];//global
dCar[playerid] = CreateVehicle(dCarID[random(sizeof(dCarID))], ... ); 
OnPlayerVehicleExit:
PHP код:
if(vehicleid == dCar[playerid])
{
      
DestroyVehicle(dCar[playerid]);
      
dCar[playerid] = 0;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)