Jump to content

Team vehicles


Xwad

Recommended Posts

Posted

Hi is there any rescource that makes possible that only team 1 can enter a vehicle. I mean for example there is a rhino and only team 1 can enter it, Thanks!

Posted (edited)

No , but it's pretty easy to create something like this.

Event; onVehicleStartEnter -- This event is triggered , when a player try to enter in a vehicle. 
Functions; 
getElementModel  -- This function will get the type of vehicle , so if it's a rhino we continue with checking of player team. 
getPlayerTeam -- This function will check have the player a team , if not we cancel the event so he can't use the rhino. 
getTeamFromName -- If the player have a team , this funtion will get the name of the team, if isn't the name you want cancel. 
cancelEvent  -- This function will cancel the event 

Edited by Guest
Posted

The script should be server side , now see the examples on wiki of the functions which i gave you , it's so easy to create that what you want , but you simply don't want to learn scripting. If you don't want to learn , pay a scripter to do those things for you. Try to create it , if you need help just say. And a answer like " i can't it " is not acceptable.

Posted

Dude , Lua is so easy. Simply don't be lazy and try it , after some time you'll learn it. And we are here to help you.

btw , i edited my post to make it more clear.

Posted

No , one file is enough. And don't think if you copy the examples from the pages it will work. Those examples are only there to make your scripting easier , and to show how the functions/events work.

Posted
Dude , Lua is so easy. Simply don't be lazy and try it , after some time you'll learn it. And we are here to help you.

btw , i edited my post to make it more clear.

Did you said the same when you just started (and no that doesn't count if you know other scripting languages)?

Posted

Et-win When i started i didn't knew any other programming language , i learned fast here on forum from watching tutorials , and editing resources from community. I simply don't understand why this guy Xward don't want to learn.

Xward What do you mean? the examples in each page are usefull.

Posted

Cool i watched a video and i learned a little bit and i have its work !!

function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle

local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle

if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400

local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle

outputChatBox ( "Someone stole a " .. vehicleName .. "!" ) -- announce that someone stole the plane

end

end

-- add the event handler to the event

addEventHandler ( "onPlayerVehicleEnter", getRootElement(), planeEnter )

Posted

ok i have read it and i made this script

#include

enum team_vehicle_info

{

v_id,//the vehicle id

v_team,//the vehicle's team id

bool:v_exist//boolean to check if vehicle exists

}

new team_vehicle[ MAX_VEHICLES ][ team_vehicle_info ];

main()

{

for(new slot; slot < MAX_VEHICLES; slot++)

{

team_vehicle[slot][v_id] = -1;//set to invalide vehicle model id

team_vehicle[slot][v_team] = NO_TEAM;//set for NO_TEAM

team_vehicle[slot][v_exist] = false;//the vehicle don't exist

}

}

stock CreateVehicleForTeam(teamid, vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay)

{

if(teamid == NO_TEAM) return false; // if the vehicle teamid is NO_TEAM(255), then this function won't work

for(new slot; slot < MAX_VEHICLES; slot++)

{

if(team_vehicle[slot][v_exist] == false)//checks if the vehicle is not created, then only proceed or else catch another loop case!

{

//creat the main vehicle and store its id

team_vehicle[slot][v_id] = CreateVehicle(vehicletype, x, y, z, rotation, color1, color2, respawn_delay);

team_vehicle[team_vehicle[slot][v_id]][v_team] = teamid;//storing the teamid

team_vehicle[team_vehicle[slot][v_id]][v_exist] = true;//setting created value "yes", so this says that the vehicle is created!

return team_vehicle[slot][v_id];//returns the vehicle id

}

}

return true;

}

stock DestoryVehicleForTeam(vehicleid)

{

DestroyVehicle(vehicleid);//destorying the vehicle

team_vehicle[vehicleid][v_team] = NO_TEAM;//set for NO_TEAM

team_vehicle[vehicleid][v_exist] = false;//the vehicle don't exist

return true;

}

public OnGameModeInit()

{

CreateVehicleForTeam(0, 413, 327.8443, -1809.2729, 4.5733, 359.3342, 91, 1, 0);//team vehicle for teamid 0

CreateVehicleForTeam(0, 467, 740.4370, -1793.5476, 12.9180, 349.2087, 58, 8, 0);//team vehicle for teamid 0

CreateVehicleForTeam(1, 473, 823.7594, -2066.2686, -0.1017, 112.6381, 56, 53,0);//team vehicle for teamid 1

CreateVehicleForTeam(1, 467, 892.0507, -1797.3351, 13.4070, 175.4098, 60, 1, 0);//team vehicle for teamid 1

return 1;

}

public OnGameModeExit()

{

DestoryVehicleForTeam(0);

DestoryVehicleForTeam(1);

DestoryVehicleForTeam(2);

DestoryVehicleForTeam(3);

return 1;

}

public OnPlayerStateChange(playerid, newstate, oldstate)

{

if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)//Player entered a vehicle as a driver

{

new vehicleid = GetPlayerVehicleID(playerid);

for(new slot; slot < MAX_VEHICLES; slot++)

{

if(team_vehicle[slot][v_exist] && vehicleid == team_vehicle[slot][v_id])//if vehicle is a team vehicle!

{

if(GetPlayerTeam(playerid) != team_vehicle[slot][v_team])//if team id don't matches

{

RemovePlayerFromVehicle(playerid);//remove the player from vehicle

GameTextForPlayer(playerid, "~r~You can't enter other team's vehicle", 3000, 3);//send the player a message

}

}

}

}

return 1;

}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...