| Blockland Forums > Modification Help |
| support_ammo.cs not working |
| (1/1) |
| Bauklotz:
--- Code: (Torque) ---package BB_support_ammo { function Player::unmountImage(%this,%slot) { Parent::unmountImage(%this,%slot); %obj.client.ammoStr = ""; } function Player::mountImage(%this,%obj,%slot) { Parent::mountImage(%this,%obj,%slot); if(!isObject(%cl = %obj.client)) return; if(strLen(%data = %this.item.ammoData) < 1) return; if(strLen(%cl.player.ammoData[%this.item]) < 1) %cl.player.ammoData[%this.item] = %data; %dataType = getField(strReplace(%cl.player.ammoData[%this.item],":","\t"),0); %typeData = getField(strReplace(%cl.player.ammoData[%this.item],":","\t"),1); switch$ (%dataType) { case mag: %str = getField(strReplace(%typeData,"/","\t"),0) @ " ("@getField(strReplace(%typeData,"/","\t"),1)@" magazine)"; case clip: %str = getField(strReplace(%typeData,"/","\t"),0) @ " (" @ getField(strReplace(%typeData,"/","\t"),1) @ " clips)"; case preloaded: %str = %typeData; default: return; } %cl.ammoStr = %str; } function ShapeBaseImageData::onFire(%this,%obj,%slot) { if( (!isObject(%cl = %obj.client)) || strLen(%cl.player.ammoData[%this.item]) < 1 ) { Parent::onFire(%this,%obj,%slot); return; } %dataType = getField(strReplace(%cl.player.ammoData[%this.item],":","\t"),0); %typeData = getField(strReplace(%cl.player.ammoData[%this.item],":","\t"),1); %itemData = getField(strReplace(%this.item.ammoData,":","\t"),1); switch$ (%dataType) { case mag: %ammo = getField(strReplace(%typeData,"/","\t"),0); %mag = getField(strReplace(%typeData,"/","\t"),1); %fullAmm = getField(strReplace(%itemData,"/","\t"),0); if(%ammo < 1 && %mag < 1) return; else if(%ammo < 1 && %mag >= %fullAmm) { %mag=%mag-%fullAmm; %ammo = %fullAmm; } else if(%ammo < 1 && (%mag < %fullAmm && %mag > 0)) { %ammo = %mag; %mag = 0; } case clip: %ammo = getField(strReplace(%typeData,"/","\t"),0); %clip = getField(strReplace(%typeData,"/","\t"),1); if(%ammo < 1 && %mag < 1) return; else if(%ammo < 1 && %mag > 0) { %mag--; %ammo = getField(strReplace(%typeData,"/","\t"),0); } case preloaded: %ammo = %typeData; if(%ammo < 1) return; default: Parent::onFire(%this,%obj,%slot); return; } Parent::onFire(%this,%obj,%slot); } }; activatePackage(BB_support_ammo); --- End code --- I have a seperate script bottomprinting "ammoStr". I have executed the following: GunItem.ammoData = "clip:12/6"; I equip a gun, I don't see it in the bottomprint. I shoot, I don't see it in the bottomprint. I keep shooting until the amount of ammo in it should be depleted. I shoot again (when I should literally have no ammo left), and a bullet appears. |
| Space Guy:
Well what have you tried doing? Do echos to see if any of your script is actually happening. First off I can see "%this.item" which is looking for the player's item variable. |
| Navigation |
| Message Index |