CarSpawner in gm
#1

Hey guys, i have added a Car Spawner in my GameMode. But I have errors when compiling.

pawn Код:
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3773) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3773) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3775) : error 017: undefined symbol "newkeys"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3777) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3779) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3783) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3786) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3787) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3792) : error 017: undefined symbol "newkeys"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3794) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3796) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3800) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3802) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3803) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3808) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3810) : error 017: undefined symbol "newkeys"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3812) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3817) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3824) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3838) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3840) : error 017: undefined symbol "newkeys"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3850) : error 017: undefined symbol "newkeys"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3852) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3855) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3856) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3857) : error 017: undefined symbol "playerid"
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(3858) : error 017: undefined symbol "playerid"

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
There is the errors lines
(All in the public OnPlayerKeyStateChange)
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);

    if(newkeys & KEY_SUBMISSION)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if(nojump2[playerid] ==1)
        {
        return 1;
        }
    if(IsPlayerInAnyVehicle(playerid))
        {
            new Float:X9, Float:Y9, Float:Z9;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9);
            SetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9+0.4);
        }
    }
    }

    if(newkeys & KEY_ANALOG_LEFT)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if(nojump2[playerid] ==1)
        {
        return 1;
        }
    if(IsPlayerInAnyVehicle(playerid))
        {
            RepairVehicle(GetPlayerVehicleID(playerid));
            SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        }
    }
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if (PRESSED(KEY_FIRE))
    {
    if(nojump2[playerid] ==1)
    {
        return 1;
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new
            VehicleID,
            VehicleModelID,
            bool:Invalid;

            VehicleID = GetPlayerVehicleID(playerid);
            VehicleModelID = GetVehicleModel(VehicleID);

            for(new a=0; a<sizeof(InvalidNosVehicles); a++)
            {
                if(VehicleModelID == InvalidNosVehicles[a])
                {
                    Invalid = true;
                    break;
                }
            }
            if(!Invalid) AddVehicleComponent(VehicleID, 1010);
        }

    if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (newkeys & KEY_FIRE)
                {
                    new Float:vehx; new Float:vehy; new Float:vehz;
                    GetVehicleVelocity(vehicleid,vehx,vehy,vehz);
                    SetVehicleVelocity(vehicleid,vehx*SpeedBoost,vehy*SpeedBoost,vehz*SpeedBoost);
                }
        }
       
    }

    if(newkeys & KEY_CROUCH)
    {
    if(IsPlayerInAnyVehicle(playerid))
        {
            new Float:PX, Float:PY, Float:PZ, Float:PA;
            GetPlayerPos(playerid, PX, PY, PZ);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
            SetVehiclePos(GetPlayerVehicleID(playerid), PX, PY, PZ+0.5);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
            RepairVehicle(GetPlayerVehicleID(playerid));
            SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        }
        else
        {
        }
    }
    }
 return 0;
}
And There is the Full code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if(newkeys == KEY_SECONDARY_ATTACK ){
        if(!IsPlayerInAnyVehicle(playerid)){
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z );
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);

            if(IsVehicleRc(vehicle)){
              PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }

        else {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
              if(GetVehicleModel(vehicleID) != D_TRAM){
                new Float:x, Float:y, Float:z;
                GetPlayerPos(playerid, x, y, z);
                SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
}
GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &veh){
    for(new i = 1; i < MAX_VEHICLES; i++){
        if(GetVehicleModel(i) > 0){
            if(GetPlayerVehicleID(playerid) != i ){
            new Float:x, Float:y, Float:z;
            new Float:x2, Float:y2, Float:z2;
            GetVehiclePos(i, x, y, z);
            x2 = x1 - x; y2 = y1 - y; z2 = z1 - z;
            new Float:vDist = (x2*x2+y2*y2+z2*z2);
            if( vDist < dist){
            veh = i;
            dist = vDist;
                }
            }
        }
    }
}
IsVehicleRc( vehicleid ){
  new model = GetVehicleModel(vehicleid);
  switch(model){
  case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_TIGER: return 1;
  default: return 0;
    }

new vehicleid = GetPlayerVehicleID(playerid);

    if(newkeys & KEY_SUBMISSION)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if(nojump2[playerid] ==1)
        {
        return 1;
        }
    if(IsPlayerInAnyVehicle(playerid))
        {
            new Float:X9, Float:Y9, Float:Z9;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9);
            SetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9+0.4);
        }
    }
    }

    if(newkeys & KEY_ANALOG_LEFT)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if(nojump2[playerid] ==1)
        {
        return 1;
        }
    if(IsPlayerInAnyVehicle(playerid))
        {
            RepairVehicle(GetPlayerVehicleID(playerid));
            SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        }
    }
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
    if (PRESSED(KEY_FIRE))
    {
    if(nojump2[playerid] ==1)
    {
        return 1;
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new
            VehicleID,
            VehicleModelID,
            bool:Invalid;

            VehicleID = GetPlayerVehicleID(playerid);
            VehicleModelID = GetVehicleModel(VehicleID);

            for(new a=0; a<sizeof(InvalidNosVehicles); a++)
            {
                if(VehicleModelID == InvalidNosVehicles[a])
                {
                    Invalid = true;
                    break;
                }
            }
            if(!Invalid) AddVehicleComponent(VehicleID, 1010);
        }

    if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (newkeys & KEY_FIRE)
                {
                    new Float:vehx; new Float:vehy; new Float:vehz;
                    GetVehicleVelocity(vehicleid,vehx,vehy,vehz);
                    SetVehicleVelocity(vehicleid,vehx*SpeedBoost,vehy*SpeedBoost,vehz*SpeedBoost);
                }
        }
       
    }

    if(newkeys & KEY_CROUCH)
    {
    if(IsPlayerInAnyVehicle(playerid))
        {
            new Float:PX, Float:PY, Float:PZ, Float:PA;
            GetPlayerPos(playerid, PX, PY, PZ);
            GetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
            SetVehiclePos(GetPlayerVehicleID(playerid), PX, PY, PZ+0.5);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
            RepairVehicle(GetPlayerVehicleID(playerid));
            SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
        }
        else
        {
        }
    }
    }
 return 0;
}
There are the defines, new and forawad :
pawn Код:
#define COLOR_BASIC              0x0066FFAA
#define COLOR_ORANGE             0xFFA500FF
#define COLOR_WHITE              0xFFFFFFFF
#define COLOR_RED                0xE60000FF
#define COLOR_GREY               0xAFAFAFAA
#define COLOR_LIGHTBLUE          0x33CCFFAA
#define COLOR_LIGHTSKYBLUE       0x87CEFAFF
#define COLOR_MEDIUMBLUE         0x0000CDFF
#define COLOR_CYAN               0x00FFFFFF
#define COLOR_DARKOLIVEGREEN     0x556B2FFF
#define COLOR_GREEN              0x9FFF00FF
#define COLOR_WHITE              0xFFFFFFFF
#define COLOR_BLUE               0x0259EAFF
#define COLOR_YELLOW             0xFFFF00AA

#pragma unused \
    ret_memcpy
   
#define DIALOGID 3300

#define SpeedBoost               1.8

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
//RC vehicles
#define RC_BANDIT   441
#define RC_BARON    464
#define RC_GOBLIN   501
#define RC_RAIDER   465
#define D_TRAM      449
#define RC_TIGER    564
#define RC_CAM      594
//Dialogs                           I'm using bigger dialog ids to don't make conflict with your server dialogs.
#define Dialog_Unique_Vehicle 10000
#define Dialog_Trailers_Vehicle 10001
#define Dialog_Boats_Vehicle 10002
#define Dialog_Station_Vehicle 10003
#define Dialog_Sport_Vehicle 10004
#define Dialog_Saloon_Vehicle 10005
#define Dialog_Public_Service_Vehicle 10006
#define Dialog_Off-Road_Vehicle 10007
#define Dialog_Low-Rider_Vehicle 10008
#define Dialog_Industry_Vehicle 10009
#define Dialog_Convertable_Vehicle 10010
#define Dialog_Bike_Vehicle 10011
#define Dialog_Helicopters 10012
#define Dialog_Airplanes 10013
#define Dialog_Rc_Vehicle 10014
#define Dialog_Vehicle 10015
//Defines
#define MAX_PLAYERVEHICLES 1
#define VehicleSpawnerLimit 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
forward VehicleSpawner(playerid,model);
forward VehicleDeleter(vehicleid);
forward VehicleReseter(vehicleid);
forward VehicleSpawnerLimiter(playerid);
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward GlobalAnnouncement();
forward Txtreset();
forward FixAllCar();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
new FixTimer;
new Text:Textdraw0;
new Text:Textdraw1;

new VehicleSpawn[MAX_PLAYERS];
new PlayerVehicle[MAX_PLAYERS][MAX_PLAYERVEHICLES];
new Turn[MAX_PLAYERS];
//vehicles
new Airplanes[] = { 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513 };
new Helicopters[] = { 548, 425, 417, 487, 488, 497, 563, 447, 469 };
new Bikes[] = { 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 471, 468, 586 };
new Convertibles[] = { 480, 533, 439, 555 };
new Industrials[] = { 499, 422, 482, 498, 609, 524, 578, 455, 403, 414, 582, 443, 514, 413, 515, 440, 543, 605, 459, 531, 408, 552, 478, 456, 554 };
new Lowriders[] = { 536, 575, 534, 567, 535, 566, 576, 412 };
new Offroad[] = { 568, 424, 573, 579, 400, 500, 444, 556, 557, 470, 489, 505, 495 };
new Public[] = { 416, 433, 431, 438, 437, 523, 427, 490, 528, 407, 544, 596, 598, 597, 599, 432, 601, 420 };
new Saloons[] = { 445, 504, 401, 518, 527, 542, 507, 562, 585, 419, 526, 604, 466, 492, 474, 546, 517, 410, 551, 516, 467, 600, 426, 436, 547, 405, 580, 560, 550, 549, 540, 491, 529, 421 };
new Sport[] = { 602, 429, 496, 402, 541, 415, 589, 587, 565, 494, 502, 503, 411, 559, 603, 475, 506, 451, 558, 477 };
new Station[] = { 418, 404, 479, 458, 561 };
new Boats[] = { 472, 473, 493, 595, 484, 430, 453, 452, 446, 454 };
new Trailers[] = { 435, 450, 591, 606, 607, 610, 569, 590, 584, 570, 608, 611 };
new Unique[] = { 485, 537, 457, 483, 508, 532, 486, 406, 530, 538, 434, 545, 588, 571, 572, 423, 442, 428, 409, 574, 449, 525, 583, 539 };
new RC_Vehicles[] = { 441, 464, 465, 501, 564, 594 };
THANKS !!!!!!!
Reply
#2

I'm sure, you wanted to add those to OnPlayerKeyStateChange.
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
   
    if(newkeys & KEY_SUBMISSION)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:X9, Float:Y9, Float:Z9;
                GetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9+0.4);
            }
        }
    }
   
    if(newkeys & KEY_ANALOG_LEFT)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
        }
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if (PRESSED(KEY_FIRE))
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }
           
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new
                VehicleID,
                VehicleModelID,
                bool:Invalid;
               
                VehicleID = GetPlayerVehicleID(playerid);
                VehicleModelID = GetVehicleModel(VehicleID);
               
                for(new a=0; a<sizeof(InvalidNosVehicles); a++)
                {
                    if(VehicleModelID == InvalidNosVehicles[a])
                    {
                        Invalid = true;
                        break;
                    }
                }
                if(!Invalid) AddVehicleComponent(VehicleID, 1010);
            }
           
            if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if (newkeys & KEY_FIRE)
                {
                    new Float:vehx; new Float:vehy; new Float:vehz;
                    GetVehicleVelocity(vehicleid,vehx,vehy,vehz);
                    SetVehicleVelocity(vehicleid,vehx*SpeedBoost,vehy*SpeedBoost,vehz*SpeedBoost);
                }
            }
           
        }
       
        if(newkeys & KEY_CROUCH)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:PX, Float:PY, Float:PZ, Float:PA;
                GetPlayerPos(playerid, PX, PY, PZ);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                SetVehiclePos(GetPlayerVehicleID(playerid), PX, PY, PZ+0.5);
                SetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
            else
            {
            }
        }
    }
pawn Код:
IsVehicleRc( vehicleid )
{
    new model = GetVehicleModel(vehicleid);
    switch(model)
    {
        case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_TIGER: return 1;
    }
    return 0;
}
Reply
#3

When i Put IsVehcileRc [blablabla] at the end of the OnPlayerKeyStateChange if i return 0 or 1 or... (lol) it show me
Pawn Compiler Library Stop Running ...
Reply
#4

Yes. The one is custom function and the other a callback. IsVehicleRc only checks if the vehicle is indeed a RC vehicle, nothing more. So the rest of the code you had, it should be in OnPlayerKeyStateChange.
Reply
#5

okay thanks
Reply
#6

This is My Script :
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if(newkeys == KEY_SECONDARY_ATTACK ){
        if(!IsPlayerInAnyVehicle(playerid)){
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z );
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);

            if(IsVehicleRc(vehicle)){
              PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }

        else {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
              if(GetVehicleModel(vehicleID) != D_TRAM){
                new Float:x, Float:y, Float:z;
                GetPlayerPos(playerid, x, y, z);
                SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
}
GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &veh){
    for(new i = 1; i < MAX_VEHICLES; i++){
        if(GetVehicleModel(i) > 0){
            if(GetPlayerVehicleID(playerid) != i ){
            new Float:x, Float:y, Float:z;
            new Float:x2, Float:y2, Float:z2;
            GetVehiclePos(i, x, y, z);
            x2 = x1 - x; y2 = y1 - y; z2 = z1 - z;
            new Float:vDist = (x2*x2+y2*y2+z2*z2);
            if( vDist < dist){
            veh = i;
            dist = vDist;
                }
            }
        }
    }
}

new vehicleid = GetPlayerVehicleID(playerid);

    if(newkeys & KEY_SUBMISSION)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:X9, Float:Y9, Float:Z9;
                GetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9+0.4);
            }
        }
    }

    if(newkeys & KEY_ANALOG_LEFT)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
        }
    }

    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if (PRESSED(KEY_FIRE))
        {
            if(nojump2[playerid] ==1)
            {
                return 1;
            }

            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new
                VehicleID,
                VehicleModelID,
                bool:Invalid;

                VehicleID = GetPlayerVehicleID(playerid);
                VehicleModelID = GetVehicleModel(VehicleID);

                for(new a=0; a<sizeof(InvalidNosVehicles); a++)
                {
                    if(VehicleModelID == InvalidNosVehicles[a])
                    {
                        Invalid = true;
                        break;
                    }
                }
                if(!Invalid) AddVehicleComponent(VehicleID, 1010);
            }

            if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if (newkeys & KEY_FIRE)
                {
                    new Float:vehx; new Float:vehy; new Float:vehz;
                    GetVehicleVelocity(vehicleid,vehx,vehy,vehz);
                    SetVehicleVelocity(vehicleid,vehx*SpeedBoost,vehy*SpeedBoost,vehz*SpeedBoost);
                }
            }

        }

        if(newkeys & KEY_CROUCH)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:PX, Float:PY, Float:PZ, Float:PA;
                GetPlayerPos(playerid, PX, PY, PZ);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                SetVehiclePos(GetPlayerVehicleID(playerid), PX, PY, PZ+0.5);
                SetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
            else
            {
            }
        }
    }
 return 1;
}
And
pawn Код:
IsVehicleRc( vehicleid )
{
    new model = GetVehicleModel(vehicleid);
    switch(model)
    {
        case RC_GOBLIN, RC_BARON, RC_BANDIT, RC_RAIDER, RC_TIGER: return 1;
    }
    return 0;
}
And when i compile... Pawn Compiler Library has stopped working....
WWWWWHHHHHHHHYYYYYYYYYY ?
Reply
#7

I told you inside the OnPlayerKeyStateChange. You added it after GetVehicleWithinDistance.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   
    if(newkeys & KEY_SECONDARY_ATTACK )
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z );
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
           
            if(IsVehicleRc(vehicle)) PutPlayerInVehicle(playerid, vehicle, 0);
        }
       
        else
        {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM)
            {
                if(GetVehicleModel(vehicleID) != D_TRAM)
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    new vehicleid = GetPlayerVehicleID(playerid);
   
    if(newkeys & KEY_SUBMISSION)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1) return 1;
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:X9, Float:Y9, Float:Z9;
                GetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9);
                SetVehicleVelocity(GetPlayerVehicleID(playerid), X9,Y9,Z9+0.4);
            }
        }
    }
   
    if(newkeys & KEY_ANALOG_LEFT)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(nojump2[playerid] ==1) return 1;
            if(IsPlayerInAnyVehicle(playerid))
            {
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
        }
    }
   
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if (PRESSED(KEY_FIRE))
        {
            if(nojump2[playerid] ==1) return 1;
           
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new
                VehicleID,
                VehicleModelID,
                bool:Invalid;
               
                VehicleID = GetPlayerVehicleID(playerid);
                VehicleModelID = GetVehicleModel(VehicleID);
               
                for(new a=0; a<sizeof(InvalidNosVehicles); a++)
                {
                    if(VehicleModelID == InvalidNosVehicles[a])
                    {
                        Invalid = true;
                        break;
                    }
                }
                if(!Invalid) AddVehicleComponent(VehicleID, 1010);
            }
           
            if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if (newkeys & KEY_FIRE)
                {
                    new Float:vehx; new Float:vehy; new Float:vehz;
                    GetVehicleVelocity(vehicleid,vehx,vehy,vehz);
                    SetVehicleVelocity(vehicleid,vehx*SpeedBoost,vehy*SpeedBoost,vehz*SpeedBoost);
                }
            }
           
        }
       
        if(newkeys & KEY_CROUCH)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:PX, Float:PY, Float:PZ, Float:PA;
                GetPlayerPos(playerid, PX, PY, PZ);
                GetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                SetVehiclePos(GetPlayerVehicleID(playerid), PX, PY, PZ+0.5);
                SetVehicleZAngle(GetPlayerVehicleID(playerid), PA);
                RepairVehicle(GetPlayerVehicleID(playerid));
                SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
            }
        }
    }
    return 1;
}

GetVehicleWithinDistance( playerid, Float:x1, Float:y1, Float:z1, Float:dist, &veh){
    for(new i = 1; i < MAX_VEHICLES; i++){
        if(GetVehicleModel(i) > 0){
            if(GetPlayerVehicleID(playerid) != i ){
                new Float:x, Float:y, Float:z;
                new Float:x2, Float:y2, Float:z2;
                GetVehiclePos(i, x, y, z);
                x2 = x1 - x; y2 = y1 - y; z2 = z1 - z;
                new Float:vDist = (x2*x2+y2*y2+z2*z2);
                if( vDist < dist){
                    veh = i;
                    dist = vDist;
                }
            }
        }
    }
}
Reply
#8

Oh XD
Reply
#9

Got these Warnings (THANKS YOU ARE MY HERO) :
pawn Код:
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(9275) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(9275) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Users\Adam\Desktop\samp\gamemodes\AdamoneoonePlanet - Copie.pwn(9275) : warning 219: local variable "Z" shadows a variable at a preceding level
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Warnings.
.
There is the public where is the error line :
pawn Код:
public VehicleDeleter(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++){
        new Float:X,Float:Y,Float:Z;
        if(IsPlayerInVehicle(i, vehicleid)){
            RemovePlayerFromVehicle(i);
            GetPlayerPos(i,X,Y,Z);
            SetPlayerPos(i,X,Y+3,Z);
        }
        SetVehicleParamsForPlayer(vehicleid,i,0,1);
    }
    SetTimerEx("VehicleReseter",2000,0,"i",vehicleid);
}
Reply
#10

You've declared them already. Just change the variables' name.
pawn Код:
public VehicleDeleter(vehicleid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        new Float:_X,Float:_Y,Float:_Z;
        if(IsPlayerInVehicle(i, vehicleid))
        {
            RemovePlayerFromVehicle(i);
            GetPlayerPos(i,_X,_Y,_Z);
            SetPlayerPos(i,_X,_Y+3,_Z);
        }
        SetVehicleParamsForPlayer(vehicleid,i,0,1);
    }
    SetTimerEx("VehicleReseter",2000,0,"i",vehicleid);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)