18.09.2008, 18:01
i add Carmod mode for trunk storing weapons i try to store the weapons they say you can`t open the trunk ....
here the codes
wath`s the problem
here the codes
Код:
if(!strcmp("/storeweapon", cmdtext, true)) { new counter = 0 new result new plyName[MAX_PLAYER_NAME] GetPlayerName(playerid, plyName, MAX_PLAYER_NAME) for(new i; i != MAX_VEHICLES; i++) { new dist = CheckPlayerDistanceToVehicle(5.0, playerid, i) if(dist) { result = i counter++ } } switch(counter) { case 0: { SendClientMessage(playerid, 0xFF0000FF, "[CARMOD] No car located near you.") } case 1: { if(vehTrunkCounter[result] != (MAX_TRUNK_SLOTS-1)) { if(!IsPlayerInAnyVehicle(playerid)) { new buffer[512] new gunname[100] new gunID = GetPlayerWeapon(playerid) new gunAmmo = GetPlayerAmmo(playerid) new plyWeapons[12] new plyAmmo[12] if(gunID != 0) { GetWeaponName(gunID, gunname, sizeof(gunname)) // Step 1: Store all the players guns (except for the one being put in the car.) for(new slot = 0; slot != 12; slot++) { new wep, ammo GetPlayerWeaponData(playerid, slot, wep, ammo) if(wep != gunID) { GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]) } } // Step 2: Store the gun being put in the car and display the message. vehTrunkCounter[result]++ vehTrunk[result][vehTrunkCounter[result]] = gunID vehTrunkAmmo[result][vehTrunkCounter[result]] = gunAmmo format(buffer, sizeof(buffer), "[CARMOD] You put your %s (AMMO: %i) in the car's trunk.", gunname, gunAmmo) SendClientMessage(playerid, 0xFF0000FF, buffer) // This adds back your guns EXCEPT for the one stored. ResetPlayerWeapons(playerid) for(new slot = 0; slot != 12; slot++) { GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]) } }else{ SendClientMessage(playerid, 0xFF0000FF, "[CARMOD] You can't store your hands in the car!") } }else{ SendClientMessage(playerid, 0xFF0000FF, "[CARMOD] You couldn't open the trunk.") } }else{ SendClientMessage(playerid, 0xFF0000FF, "[CARMOD] This car's trunk is full.") } } default: { SendClientMessage(playerid, 0xFF0000FF, "[CARMOD] More than one car detected detected in the vercinity.") } } return 1 }