SA-MP Forums Archive
[HELP] Many private cars - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Many private cars (/showthread.php?tid=272415)



[HELP] Many private cars - agreathon - 28.07.2011

How can I make this code more private cars?

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
pname[MAX_PLAYER_NAME];
    new 
car;
    
car AddStaticVehicle(437,-709.94384766,912.88665771,12.69688034,90.00000000,-1,3);
    
GetPlayerName(playeridpnamesizeof pname);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
vehicleid == car)
        {
            if(
strcmp(pname"Name"true) == 0)
              {
                return 
1;
            }
            else
              {
              
RemovePlayerFromVehicle(playerid);
            new 
string[50];
            
format(stringsizeof(string), "~r~This car is private!");
            
GameTextForPlayer(playeridstring30004);
            }
        }
}
    return 
1;

To not do so on each machine:
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
pname[MAX_PLAYER_NAME];
    new 
car2;
    
car2 AddStaticVehicle(437,-709.94384766,912.88665771,12.69688034,90.00000000,-1,3);
    
GetPlayerName(playeridpnamesizeof pname);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
vehicleid == car2)
        {
            if(
strcmp(pname"Name"true) == 0)
              {
                return 
1;
            }
            else
              {
              
RemovePlayerFromVehicle(playerid);
            new 
string[50];
            
format(stringsizeof(string), "~r~This car is private!");
            
GameTextForPlayer(playeridstring30004);
            }
        }
}
    return 
1;




Re: [HELP] Many private cars - Basicz - 28.07.2011

pawn Код:
new
    car[ 2 ] // increase the size to create more private vehs
;

public OnGameModeInit( )
{
    car[ 0 ] = addstaticveh....
    car[ 1 ] = addstaticveh....
    // why no 2 when the car[ 2 ] ? because it starts from 0.

    return 1;
}

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

    GetPlayerName(playerid, pname, sizeof pname);

    if(newstate == PLAYER_STATE_DRIVER)
    {
        for ( new j = sizeof ( car ), i; i < j; i ++ ) // if its not working try 'for ( new j = sizeof ( car - 1 ), i; i < j; i ++ )
        {
            if ( vehicleid == car[ j ] )
            {
                if(strcmp(pname, "Name", true) == 0)
                {
                    return 1;
                }
                else
                {
                      RemovePlayerFromVehicle(playerid);
                     new string[50];
                     format(string, sizeof(string), "~r~This car is private!");
                     GameTextForPlayer(playerid, string, 3000, 4);
                }
             }
         }
    }
    return 1;
}
Hope it helps


Re: [HELP] Many private cars - agreathon - 28.07.2011

Quote:
Originally Posted by Basicz
Посмотреть сообщение
pawn Код:
new
    car[ 2 ] // increase the size to create more private vehs
;

public OnGameModeInit( )
{
    car[ 0 ] = addstaticveh....
    car[ 1 ] = addstaticveh....
    // why no 2 when the car[ 2 ] ? because it starts from 0.

    return 1;
}

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

    GetPlayerName(playerid, pname, sizeof pname);

    if(newstate == PLAYER_STATE_DRIVER)
    {
        for ( new j = sizeof ( car ), i; i < j; i ++ ) // if its not working try 'for ( new j = sizeof ( car - 1 ), i; i < j; i ++ )
        {
            if ( vehicleid == car[ j ] )
            {
                if(strcmp(pname, "Name", true) == 0)
                {
                    return 1;
                }
                else
                {
                      RemovePlayerFromVehicle(playerid);
                     new string[50];
                     format(string, sizeof(string), "~r~This car is private!");
                     GameTextForPlayer(playerid, string, 3000, 4);
                }
             }
         }
    }
    return 1;
}
Hope it helps
Thanks, but still no works with successful compilation.


Re: [HELP] Many private cars - agreathon - 28.07.2011

There are alternatives?


Re: [HELP] Many private cars - (SF)Noobanatior - 28.07.2011

that will only let you have it if your name is name how do you know who the owner is?


Re: [HELP] Many private cars - Basicz - 28.07.2011

Hmm, it should works.
Did you even see this comment?

pawn Код:
// if its not working try 'for ( new j = sizeof ( car - 1 ), i; i < j; i ++ )
Don't create vehicle on OnPlayerStateChange