Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- BULLET_HIT_TYPE_NONE //called if the player does not shoot.
- BULLET_HIT_TYPE_PLAYER //called if the player shoots the player.
- BULLET_HIT_TYPE_VEHICLE //called if the player shoots a car.
- BULLET_HIT_TYPE_OBJECT //called if the player shoots an object.
- BULLET_HIT_TYPE_PLAYER_OBJECT //called if the player shoots the created object.
- */
- new ObjectHP[MAX_OBJECTS];
- public OnGameModeInit()
- {
- //We reset the hp.
- for(new i; i< MAX_OBJECTS; i++) ObjectHP[i] = 0;
- CreateObject(18848, 1450.59, -2446.57, 12.50, 0.00, 0.00, 0.00);
- CreateObject(18848, 1442.11, -2444.87, 12.55, 0.00, 0.00, 0.00);
- CreateObject(18848, 1461.18, -2446.89, 12.54, 0.00, 0.00, 0.00);
- CreateObject(18848, 1457.31, -2430.67, 12.54, 0.00, 0.00, 0.00);
- CreateObject(18848, 1449.48, -2430.51, 12.54, 0.00, 0.00, 0.00);
- //HP setting.
- for(new i; i< MAX_OBJECTS; i++)
- {
- if(!IsValidObject(i)) continue; //If the object is not working
- ObjectHP[i] = 100; //100 hp for faster destruction.
- }
- return 1;
- }
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if(hittype == BULLET_HIT_TYPE_OBJECT) //In case the player hits the object
- {
- if(IsValidObject(hitid))
- {
- ObjectHP[hitid] -= random(10) + 1;
- if(ObjectHP[hitid] >= 0)
- {
- new str[128];
- format(str, sizeof(str), "~G~OBJECT DAMAGED!~N~~Y~OBJECT ID ~W~: ~R~ %d~N~~Y~HP LEFT ~W~: ~R~
- %d",hitid,ObjectHP[hitid]);
- }
- if(ObjectHP[hitid] <= 0)
- {
- DestroyObject(hitid);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment