need help with carshop
#1

hi, i creating carshop and created somethin stuck with this:
how to make it: with same CMD change cars now its many CMD like this:
Code:
if(!strcmp(cmdtext, "/pirmyn", true,17))
{
        DestroyVehicle(vehic[0]);
        vehic[1] = CreateVehicle(401,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        return 1;
}
if(!strcmp(cmdtext, "/pirmyn2", true,17))
{
        DestroyVehicle(vehic[1]);
        vehic[2] = CreateVehicle(402,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        return 1;
}
how to do that /pirmyn change first in vehic[1] then if you write /pirmyn again it change car in : vehic[2]

Can anyone help me
Reply
#2

pawn Code:
new vehid; // at the top of the script

if(!strcmp(cmdtext, "/pirmyn", true,17))
{
        DestroyVehicle(vehic[vehid]);
        vehid++
        vehic[vehid] = CreateVehicle(401,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        return 1;
}
here you are
Reply
#3

Quote:
Originally Posted by tour15
View Post
pawn Code:
new vehid; // at the top of the script

if(!strcmp(cmdtext, "/pirmyn", true,17))
{
        DestroyVehicle(vehic[vehid]);
        vehid++
        vehic[vehid] = CreateVehicle(401,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        return 1;
}
here you are
and how i need to select cars whos be shown?
Reply
#4

Added a few things
I've set the 'vehid' to 400 (model id starts with 400)
Added a check to see if the model id is more than 400 and less than 611 (model id ends at 611)

pawn Code:
/* new vehid; // at top of the script if you are using it global */

if(!strcmp(cmdtext, "/pirmyn", true))
{
        new vehid;
        if(vehid >= 400 && vehid <= 611)
        {
            vehid = 400;
            DestroyVehicle(vehic[vehid]);
            vehid++;
            vehic[vehid] = CreateVehicle(400,-1954.6177,260.2105,35.5101,33.9648,0,0,-1); // vehicles start with 400
        }
        else
        {
            vehid = 400;
        }
        return 1;
}
Reply
#5

Quote:
Originally Posted by Pinguinn
View Post
Added a few things
I've set the 'vehid' to 400 (model id starts with 400)
Added a check to see if the model id is more than 400 and less than 611 (model id ends at 611)

pawn Code:
/* new vehid; // at top of the script if you are using it global */

if(!strcmp(cmdtext, "/pirmyn", true))
{
        new vehid;
        if(vehid >= 400 && vehid <= 611)
        {
            vehid = 400;
            DestroyVehicle(vehic[vehid]);
            vehid++;
            vehic[vehid] = CreateVehicle(400,-1954.6177,260.2105,35.5101,33.9648,0,0,-1); // vehicles start with 400
        }
        else
        {
            vehid = 400;
        }
        return 1;
}
but if i whant to set only few cars ex: 400 450 and 511 what then?
Reply
#6

Try using if and else if

Something like this

On the top of your script

pawn Code:
#define LATEST_VEHID 3 // change this
new vehid = 0;
pawn Code:
if(!strcmp(cmdtext, "/pirmyn", true))
{
        DestroyVehicle(GetPlayerVehicleID(playerid));
        vehid++;
        if(vehid == 1)
        {
            CreateVehicle(400,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        }
        else if(vehid == 2)
        {
            CreateVehicle(450,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        }
        else if(vehid == 3)
        {
            CreateVehicle(511,-1954.6177,260.2105,35.5101,33.9648,0,0,-1);
        }
        return 1;
}
And at OnPlayerKeyStateChange you can do something like

pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new keys, ud, lr;
    GetPlayerKeys(playerid, keys, ud, lr);
    if(lr > 0)
    {
        vehid++;
    }
    else if(lr < 0)
    {
        if(vehid <= 0)
        {
            vehid = LATEST_VEHID;
        }
        else
        {
            vehid--;
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)