Developed by DoktorSAS
- fed for helping with the plugin
Through these files it will be possible to get the Gun Locker Fully Working. Implementing the following scripts is very easy. In order to make the IW4M admin plugin work you also need to modify the mod in your server. You will have to add some lines of code
- IW4M Admin: To have the gun locker running on a server you must have IW4M
Everything has been done to make it as simple as possible, in fact it's just a few lines of code to add to a mod and a plugin to insert in the plugin folder of iw4m admin.
To implement these features takes two minutes, just follow this guide carefully and you will understand how to implement the bank on your servers.
- Download the compiled files and not the source code
- Take/Copy the GunLockerFix.dll file and put it in the plugins folder of IW4M Admin
- Open your not compiled mod file with GSC Studio or other text editor
- Add to your init function this lines of code
if (getDvar("mapname") == "zm_buried" || getDvar("mapname") == "zm_highrise" || getDvar("mapname") == "zm_transit") {
level thread onPlayerConnect_gun_locker_fix();
level thread onEndGame_gun_locker_fix();
}
like
init(){
if (getDvar("mapname") == "zm_buried" || getDvar("mapname") == "zm_highrise" || getDvar("mapname") == "zm_transit") {
level thread onPlayerConnect_gun_locker_fix();
level thread onEndGame_gun_locker_fix();
}
}
- Add the this other funciton where you want in the mod
onEndGame_gun_locker_fix(){
level waittill("end_game");
foreach(player in level.players){
if(isDefined(player.stored_weapon_data)){
new_dvar_value = "IW4MLOCKER;" + player.guid + "," + player.stored_weapon_data["name"] + "," + player.stored_weapon_data["lh_clip"] + "," + player.stored_weapon_data["clip"] + "," + player.stored_weapon_data["stock"] + "," + player.stored_weapon_data["alt_clip"] + "," + player.stored_weapon_data["alt_stock"];
logPrint(new_dvar_value + "\n");
}else{
new_dvar_value = "IW4MLOCKER;" + player.guid + "," + "none";
logPrint(new_dvar_value + "\n");
}
}
}
onPlayerConnect_gun_locker_fix(){
for(;;){
level waittill("connected", player);
player thread gun_locker_fix();
player thread onPlayerDisconnect_gun_locker_fix();
}
}
onPlayerDisconnect_gun_locker_fix(){
self waittill("disconnect");
stored_weapon_data = self.stored_weapon_data;
guid = self.guid;
if(isDefined(self.stored_weapon_data)){
new_dvar_value = "IW4MLOCKER;" + guid + "," + stored_weapon_data["name"] + "," + stored_weapon_data["lh_clip"] + "," + stored_weapon_data["clip"] + "," + stored_weapon_data["stock"] + "," + stored_weapon_data["alt_clip"] + "," + stored_weapon_data["alt_stock"];
logPrint(new_dvar_value + "\n");
}else{
new_dvar_value = "IW4MLOCKER;" + guid + "," + "none";
logPrint(new_dvar_value + "\n");
}
}
gun_locker_fix(){
level endon("end_game");
self waittill("spawned_player");
while(getDvar( "guns_clients_information" ) == "" || !self setLockerGun( )) // As long as the value of the bank is not valid then it remains in the loop
wait 0.001;
}
setLockerGun( ) {
guns_data = strTok(getDvar( "guns_clients_information" ), "-"); // The dvar is divided into many elements so many players are in game
for (i = 0; i < guns_data.size; i++) {
client_data = strTok(guns_data[i], ","); // Divides each player's data into arrays with 7 values
if (int(client_data[0]) == int(self.guid)) { // If the GUID matches the user in analysis then sets the value of the stored weapondata and says that the value is valid
weapondata = [];
if(client_data[1] != "none"){
weapondata[ "name" ] = client_data[1];
weapondata[ "lh_clip" ] = client_data[2];
weapondata[ "clip" ] = client_data[3];
weapondata[ "stock" ] = client_data[4];
weapondata[ "alt_clip" ] = client_data[5];
weapondata[ "alt_stock" ] = client_data[6];
self.stored_weapon_data = weapondata;
self iprintln("Weapon Set!");
}
return 1;
}
}
return 0;
}
- Compile the file
- Put the compiled file in maps\mp\gametypes_zm
- Start the server
- Start IW4M
- END
Download the files from Github
Download and/or read the source files from Github