07.04.2009, 10:14
Quote:
Originally Posted by kimse007
Hello there..
I am currently trying to learn PAWN. Until now I have learnt the basic I think(Iґll show what I have scripted later). My next step is to make a faction. I have went through GF and PEN1 but I canґt find the exactly way to do it in. So if anybody can post a link or can show how to make a simpel faction with 2 ranks and explain deeply what you did, I would appreciate that. |
First you need to find a way to seperate faction players from another. That can be done with enum and array. It is very comfortable to use and you can save all player specific data in one place. Read more about it from here - About Enums.
Once you can tell difference between player in faction and regular player ( if( PlayerInfo[playerid][Faction] == 1 ) ..... ) you can start adding other stuff.
For example to create a faction vehicle you could do:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if( PlayerInfo[playerid][Faction] != 1 && vehicleid == FactionCar ) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid, COLOR_WHITE, "This is a faction car!"); } return 1; }
Код:
new vehicleid = CreateVehicle(...); VehicleInfo[factioncar][FactionCar] = 1; ... ... ... public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if( VehicleInfo[vehicleid][FactionCar] ) { if( PlayerInfo[playerid][Faction] != VehicleInfo[vehicleid][FactionCar] ) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid, COLOR_WHITE, "This is a faction car!"); } } return 1; }
Adding ranks is just the same. Like adding another faction in the faction. Add "FactionRank" to PlayerInfo and "CarRank" to vehicleinfo .Now for ranked faction vehicle for example you could do something like
Код:
new vehicleid = CreateVehicle(...); VehicleInfo[factioncar][FactionCar] = 1; ... ... ... public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if( VehicleInfo[vehicleid][FactionCar] ) { if( PlayerInfo[playerid][Faction] == VehicleInfo[vehicleid][FactionCar] && PlayerInfo[playerid][FactionRank] >= VehicleInfo[vehicleid][CarRank] ) { SendClientMessage(playerid, COLOR_WHITE, "Welcome to your faction car!"); } else { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid, COLOR_WHITE, "You are not allowed to use this vehicle!"); } } return 1; }