Linking a skin to all of a vehicle ID
#1

Hello, Ive been searching around.. and cant find any help but iam kind of new to PAWN.. But What Iam asking is how do I link like Skin id's "275-276" To lets say an Ambulance.. And only that skin can get in that vehicle? If you dont have the skin it kicks you out and then
Код:
SendClientMessage(playerid, COLOR_YELLOW, "You are not a medic!");
Or if you cannot help me here, I have Grove Vs Police.. With a grove medic and a Police medic... How do I make it to where only the two medics can enter the Ambulances?
Sorry if I didnt word it very good.. I just am tired, And Ive been searching all day.
-Thank you, Jacob
Reply
#2

Look for OnPlayerStateChange in your script.

Replace
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}
With:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) == 416)
        {
            if(GetPlayerSkin(playerid) == 256 || GetPlayerSkin(playerid) == 257) return 1;
            else
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_YELLOW, "You are not a medic.");
            }
        }
    }
    return 1;
}

And that should do it.

I actually shouldn't give you the code but I'm feeling nice, And I know there are probebly better ways to solve this.
Reply
#3

Its not working, It doesnt remove any of the other skins besides the medic skins. Any help? Thanks
Reply
#4

He seems to have mixed Vehicle ID with Model ID.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    switch(newstate)
    {
        case PLAYER_STATE_DRIVER,PLAYER_STATE_PASSENGER:
        {
            if(GetVehicleModel(GetPlayerVehicleID(playerid))==416) //If the player's vehicle id's model is the ambulance
            {
                new skin=GetPlayerSkin(playerid);
                if( (skin!=X) && (skin!=X) )
                {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid,0xFF0000FF,"You are not a medic");
                }
            }
        }
    }
    return 1;
}
Reply
#5

Why not just set players into teams would make things a lot easier
Reply
#6

Quote:

He seems to have mixed Vehicle ID with Model ID.

Yeah I did, sorry 'bout that. I was tired in a hurry..


Quote:

Why not just set players into teams would make things a lot easier

Depends on what kindof script you are making I guess.
This only makes sure you have to use the a medic skin to drive the ambulance.. Nothing said about teams.
Reply
#7

I fine it easyier to just set skins to vehicles, Its more efficient for the type of server iam making, And its new PAWNO Programmer friendly, Thanks for the help guys.

Quote:
Originally Posted by hoodline
Посмотреть сообщение
Why not just set players into teams would make things a lot easier
I have teams.. Its Police VS Grove, But Iam new like I said, And confused.. Still learning





Код:
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(295) : warning 217: loose indentation
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(549) : error 003: declaration of a local variable must appear in a compound block
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(549) : warning 217: loose indentation
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(549) : error 017: undefined symbol "skin"
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(550) : error 017: undefined symbol "skin"
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(557) : error 010: invalid function or declaration
C:\Program Files (x86)\Rockstar Games\GTA San Andreas 2\Server\gamemodes\RS.pwn(683) : warning 203: symbol is never used: "ret_memcpy"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
This is what Throws me off.. When the skin is defined in the code its self.
Reply
#8

public OnPlayerStateChange(playerid,newstate,oldstate)
{
switch(newstate)
{
case PLAYER_STATE_DRIVER,PLAYER_STATE_PASSENGER:
{
if(GetVehicleModel(GetPlayerVehicleID(playerid))== 416) //If the player's vehicle id's model is the ambulance
{
new skin=GetPlayerSkin(playerid);
if( (skin!=X && skin!=X)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xFF0000FF,"You are not a medic");
}
}
}
}
return 1;
}
Reply
#9

You just copied what he put.. wtf
Reply
#10

This will work if you set their skin before the vehicles streams in (when they login, or far away from the ambulances, or in an interior). If you do not, the ambulance will remain locked even with the skin.

However, you can unlock the vehicle with
pawn Код:
SetVehicleParamsForPlayer(vehicleid,playerid,0,0);
whenever you set the skin, and If you're close to the vehicles It will still unlock.
But you must have the code under OnVehicleStreamIn.

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    new skin = GetPlayerSkin(playerid);
    new model = GetVehicleModel(vehicleid);

    if(model==416)
    {
        if(skin==275 || skin==276)
        {
            SetVehicleParamsForPlayer(vehicleid,playerid,0,0);
        }
        else
        {
            SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)