more than one private car/personal car
#1

hello i created this by watching a video tutorial on *******

pawn Код:
new vcar

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid =GetPlayerVehicleID(playerid);
    new pname[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pname, sizeof pname);
    if (newstate == PLAYER_STATE_DRIVER)
    {
         if (vehicleid == vcar)
         {
              if(strcmp(pname, "[XL]kaos999", true) == 0)

              {
                  SendClientMessage(playerid, COLOR_RED, "WELCOME VIP[XL]KAOS999");
                  return 1;
              }
              else

              {
                  RemovePlayerFromVehicle(playerid);
                  SendClientMessage(playerid, COLOR_RED, "THIS VEHICLE ONLY BELONGS TO VIP[XL]KAOS999");
              }
         }
    }
    return 1;
}

public OnFilterScriptInit()
{
    vcar = AddStaticVehicleEx(579, 263.2821, -1377.5272, 53.0415, 305.2861, 1, 1, 15);


    return 1;
}
and it works fine but one big problem is there any way i can add private cars more the easy way and not only two i want like 20-25 so please if any one knows an easy method to add more reply asap
Reply
#2

Based on the system you're using..

pawn Код:
new vcars[25];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid =GetPlayerVehicleID(playerid);
    new pname[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pname, sizeof pname);
    if (newstate == PLAYER_STATE_DRIVER)
    {
         if (vehicleid == vcar[0])
         {
              if(strcmp(pname, "[XL]kaos999", true) == 0)

              {
                  SendClientMessage(playerid, COLOR_RED, "WELCOME VIP[XL]KAOS999");
                  return 1;
              }
              else

              {
                  RemovePlayerFromVehicle(playerid);
                  SendClientMessage(playerid, COLOR_RED, "THIS VEHICLE ONLY BELONGS TO VIP[XL]KAOS999");
              }
         }
    }
    return 1;
}
It works like this:

pawn Код:
vcar[0] = CreateVehicle(...);
vcar[1] = CreateVehicle(...);
vcar[2] = CreateVehicle(...);
vcar[etc..] = CreateVehicle(...);
Reply
#3

ok thanks i give it ago but not still not sure how will you name each player to each car??
Reply
#4

You could do this.

pawn Код:
new vcar_names[MAX_PLAYER_NAME][25];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid =GetPlayerVehicleID(playerid);
    new pname[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pname, sizeof pname);
    if (newstate == PLAYER_STATE_DRIVER)
    {
         if (vehicleid == vcar[0])
         {
              if(strcmp(pname, vcar_names[0] true) == 0)

              {
                  SendClientMessage(playerid, COLOR_RED, "WELCOME VIP");
                  return 1;
              }
              else

              {
                  RemovePlayerFromVehicle(playerid);
                  SendClientMessage(playerid, COLOR_RED, "THIS VEHICLE DOES NOT BELONG TO YOU");
              }
         }
    }
    return 1;
}


// then you create them this way, setting their name/owner

vcar[0] = CreateVehicle(...);
vcar_names[0] = "Marricio";
vcar[1] = CreateVehicle(...);
vcar_names[1] = "John";
vcar[2] = CreateVehicle(...);
vcar_names[2] = "kaos999";
vcar[etc..] = CreateVehicle(...);
vcar_names[etc..] = "anyname";
Reply
#5

yh i think this way is better thanks
Reply
#6

ok i done added this and i got errors (at the bottom)
btw did i mention that im a noob scripter so please explain like if your are explaining to a baby AND THANKS IN ADVANCE AND THANK YOU MARRICIO

pawn Код:
new vcar_names[MAX_PLAYER_NAME][25];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid =GetPlayerVehicleID(playerid);
    new pname[MAX_PLAYER_NAME];
   

    GetPlayerName(playerid, pname, sizeof pname);
    if (newstate == PLAYER_STATE_DRIVER)
    {
         if (vehicleid == vcar[0])      //=============line 1422
         {
              if(strcmp(pname, vcar_names[0] true) == 0)

              {
                  SendClientMessage(playerid, COLOR_RED, "WELCOME VIP");
                  return 1;
              }
              else

              {
                  RemovePlayerFromVehicle(playerid);
                  SendClientMessage(playerid, COLOR_RED, "THIS VEHICLE DOES NOT BELONG TO YOU");
              }
         }
    }
    return 1;
}


// then you create them this way, setting their name/owner

vcar[0] = CreateVehicle(421, 1766.8463, -2116.9495, 13.3474, 269.9729, 166, 166, 30);
vcar_names[0] = "[XL]KAOS";
i get these errors
pawn Код:
:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1380) : warning 202: number of arguments does not match definition
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1422) : error 017: undefined symbol "vcar"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1422) : warning 215: expression has no effect
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1422) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1422) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SA SERVER\OFFICAL SERVER\gamemodes\xlgwolds.pwn(1422) : fatal error 107: too many error messages on one line
Reply
#7

Care to explain what errors you are getting?
Reply
#8

Quote:
Originally Posted by Isolated
Посмотреть сообщение
Care to explain what errors you are getting?
sorry i added them
Reply
#9

pawn Код:
if(strcmp(pname, vcar_names[0] true) == 0)
// change
if(strcmp(pname, vcar_names[pname][0], true) == 0)

it's 3am so don't blame me if it fails to work, I'll fix it if not in the morning.
Reply
#10

I guess you forgot to add this under the vcar_name :P

pawn Код:
new vcars[25];
Also, Isolated the code you posted is wrong, the problem is that he forgot to create the variable. Using strcmp that way wouldn't fix it (y)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)