SA-MP Forums Archive
Vehicles Random ID's - 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)
+--- Thread: Vehicles Random ID's (/showthread.php?tid=587618)



Solved thank's for @Jeff - Sn4ke2 - 01.09.2015

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


Re: Vehicles Random ID's - saffierr - 01.09.2015

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


Re: Vehicles Random ID's - Sn4ke2 - 01.09.2015

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); 



Re: Vehicles Random ID's - GatsbyTrieu - 01.09.2015

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);  




Re: Vehicles Random ID's - Sn4ke2 - 01.09.2015

This what you say i will make inside command ?


Re: Vehicles Random ID's - Jefff - 01.09.2015

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

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



Re: Vehicles Random ID's - Sn4ke2 - 01.09.2015

i make it inside the command and now cont create the vehicle


Re: Vehicles Random ID's - Sn4ke2 - 01.09.2015

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


Re: Vehicles Random ID's - Sn4ke2 - 01.09.2015

@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


Re: Vehicles Random ID's - MarvinPWN - 01.09.2015

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;