#1

I have tried playing around with this but it just makes pawno crash. Anyways, I have 5 mechanic vehicles and I wan't it so only people with the mechanic job can enter the vehicles. If you could tell me how I'd do that, then it'd be great.
Код HTML:
        AddStaticVehicle(525,1897.2861,-1874.5471,13.4254,90.3112,44,51); //
	AddStaticVehicle(525,1897.3396,-1863.3942,13.5911,90.1349,22,30); //
	AddStaticVehicle(525,1897.6108,-1868.9780,13.4919,90.9807,36,43); //
	AddStaticVehicle(525,1897.5637,-1857.8895,13.6275,90.9819,18,20); //
	AddStaticVehicle(525,1897.2646,-1852.4352,13.7077,90.2574,17,20); //
Reply
#2

There no problem in this code. Maybe your other script line f**ked. Thats hwy pawno crashing. Check the script and tell us again
Reply
#3

Try using this .. - https://sampwiki.blast.hk/wiki/AddStaticVehicleEx
Reply
#4

What errors are you getting when pawno crashes?
Reply
#5

Maybe problem with includes, check them out. And what error pawno gives when it crashed?
Reply
#6

Show the Error of your Pawno Compiler.

Here is the code of only mechanic can enter in mechanic vehicle.
Код:
new mech_vehicles[5];
new Mechanic[MAX_PLAYERS];

mech_vehicles[0] = AddStaticVehicle(525,1897.2861,-1874.5471,13.4254,90.3112,44,51); //
mech_vehicles[1] = AddStaticVehicle(525,1897.3396,-1863.3942,13.5911,90.1349,22,30); //
mech_vehicles[2] = AddStaticVehicle(525,1897.6108,-1868.9780,13.4919,90.9807,36,43); //
mech_vehicles[3] = AddStaticVehicle(525,1897.5637,-1857.8895,13.6275,90.9819,18,20); //
mech_vehicles[4] = AddStaticVehicle(525,1897.2646,-1852.4352,13.7077,90.2574,17,20); //

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid;
    new Float:X, Float:Y, Float:Z, Float:Angle;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    vid = GetPlayerVehicleID(playerid);
    if(oldstate != PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
        if(Mechanic[playerid] == 1) return 1; // if the player is mechanic then return 1 If not then check player's vehicle
        else
        {
            for(new i = 0; i< 5; i++)
            {
                if(vid == mech_vehicle[i])
                { 
     		    SetPlayerPos(playerid,X,Y,Z+3);
     		    SetPlayerFacingAngle(playerid,Angle);
		    SendClientMessage(playerid, 0xFFFFFFFF, "This vehicle is only for Mechanics");
                }
            }
        }
    }
    return 1;
}
Reply
#7

gonna need to see the error to tell you whats wrong bud more than likely you've missed a stock or need to declare something
Reply
#8

You can-t just add the cars like this,you need to set them to work just for your factions,like VishvaJeet said.
Reply
#9

Quote:
Originally Posted by VishvaJeet
Посмотреть сообщение
Show the Error of your Pawno Compiler.

Here is the code of only mechanic can enter in mechanic vehicle.
Код:
new mech_vehicles[5];
new Mechanic[MAX_PLAYERS];

mech_vehicles[0] = AddStaticVehicle(525,1897.2861,-1874.5471,13.4254,90.3112,44,51); //
mech_vehicles[1] = AddStaticVehicle(525,1897.3396,-1863.3942,13.5911,90.1349,22,30); //
mech_vehicles[2] = AddStaticVehicle(525,1897.6108,-1868.9780,13.4919,90.9807,36,43); //
mech_vehicles[3] = AddStaticVehicle(525,1897.5637,-1857.8895,13.6275,90.9819,18,20); //
mech_vehicles[4] = AddStaticVehicle(525,1897.2646,-1852.4352,13.7077,90.2574,17,20); //

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid;
    new Float:X, Float:Y, Float:Z, Float:Angle;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    vid = GetPlayerVehicleID(playerid);
    if(oldstate != PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
        if(Mechanic[playerid] == 1) return 1; // if the player is mechanic then return 1 If not then check player's vehicle
        else
        {
            for(new i = 0; i< 5; i++)
            {
                if(vid == mech_vehicle[i])
                { 
     		    SetPlayerPos(playerid,X,Y,Z+3);
     		    SetPlayerFacingAngle(playerid,Angle);
		    SendClientMessage(playerid, 0xFFFFFFFF, "This vehicle is only for Mechanics");
                }
            }
        }
    }
    return 1;
}
I did that and got 4 errors.

Код HTML:
C:\Users\Zach\Desktop\Folders\Servers\SAMP\SamZach\gamemodes\rp.pwn(878) : error 017: undefined symbol "mech_vehicle"
C:\Users\Zach\Desktop\Folders\Servers\SAMP\SamZach\gamemodes\rp.pwn(878) : warning 215: expression has no effect
C:\Users\Zach\Desktop\Folders\Servers\SAMP\SamZach\gamemodes\rp.pwn(878) : error 001: expected token: ";", but found "]"
C:\Users\Zach\Desktop\Folders\Servers\SAMP\SamZach\gamemodes\rp.pwn(878) : error 029: invalid expression, assumed zero
C:\Users\Zach\Desktop\Folders\Servers\SAMP\SamZach\gamemodes\rp.pwn(878) : fatal error 107: too many error messages on one line
Reply
#10

First try like this. not sure about this

PHP код:
new MechVehicles];
new 
Mechanic[MAX_PLAYERS];

MechVehicles[0] = AddStaticVehicleEx(525,1897.2861,-1874.5471,13.4254,90.3112,44,51); //
MechVehicles[1] = AddStaticVehicleEx(525,1897.3396,-1863.3942,13.5911,90.1349,22,30); //
MechVehicles[2] = AddStaticVehicleEx(525,1897.6108,-1868.9780,13.4919,90.9807,36,43); //
MechVehicles[3] = AddStaticVehicleEx(525,1897.5637,-1857.8895,13.6275,90.9819,18,20); //
MechVehicles[4] = AddStaticVehicleEx(525,1897.2646,-1852.4352,13.7077,90.2574,17,20); //

public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vid;
    new 
Float:XFloat:YFloat:ZFloat:Angle;
    
GetPlayerPos(playerid,X,Y,Z);
    
GetPlayerFacingAngle(playerid,Angle);
    
vid GetPlayerVehicleID(playerid);
    if(
oldstate != PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_DRIVER// Player entered a vehicle as a driver
    
{
       
// if(Mechanic[playerid] == 1) return 1; // if the player is mechanic then return 1 If not then check player's vehicle
        
if(Mechanic[playerid] == 1) { return 1; }// use this if first one error
        
else
        {
            for(new 
0i5i++)
            {
                if(
vid == MechVehicles[i])
                { 
                 
SetPlayerPos(playerid,X,Y,Z+3);
                 
SetPlayerFacingAngle(playerid,Angle);
            
SendClientMessage(playerid0xFFFFFFFF"This vehicle is only for Mechanics");
                }
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)