All pastes #933903 Raw Edit

Mine

public text v1 · immutable
#933903 ·published 2008-03-08 15:06 UTC
rendered paste body
#include <a_samp>
#define MAX_SPRUNK 100 //Just change this if you are going ot use more than 100 sprunk machines
#define SPRUNK_PRICE 10 //how much does a can of sprunk cost?
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z, Float:RotX, Float:RotY, Float:RotZ);
forward Sprunkend(playerid);
new sprunk[MAX_SPRUNK], Float:Rot[7][MAX_SPRUNK];

public OnFilterScriptInit() {
	print("\n----------------------------------");
	print("SPRUNK SPRUNK");
	print("----------------------------------\n");
}

public OnFilterScriptExit() {
	print("\n----------------------------------");
	print("SPRUNK SPRUNK");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	AddStaticSprunk(0,852.053,-1899.893,12.270,0,0,-90.000);                             // sprunt-piti
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	
	for(new i = 0; i < MAX_SPRUNK; i++) // SPRUNK
 	{
		if(IsPlayerInSphere(playerid,851.2333,-1899.9518,12.8672,2))
		{
			if(newkeys == 16 && GetPlayerState(playerid == PLAYER_STATE_ONFOOT))
           	{
           		if(GetPlayerMoney(playerid) >= SPRUNK_PRICE)
            	{
            	    SetPlayerPos(playerid, 851.2333-0.5, -1899.9518, 12.8672);
            	    
            		TogglePlayerControllable(playerid,0);
               		ApplyAnimation(playerid,"VENDING","VEND_Use",3.0,0,0,0,0,0); //sprunk machine animation
               		PlayerPlaySound(playerid,42600,0,0,0); //sprunk machine noise - NOT SUPPORTED IN SA:MP
               		SetTimerEx("Sprunkend",3000,0,"i",playerid);
               		new cash = GetPlayerMoney(playerid);
               		ResetPlayerMoney(playerid);
               		GivePlayerMoney(playerid,cash-SPRUNK_PRICE);
            	}
				else
				{
               	  	PlayerPlaySound(playerid,1053,0,0,0); //rejected money sound - works!
				}
			}
		}
	}
  	return true;
}

// SPRUNT MACHINE by GROVE

stock AddStaticSprunk(id,Float:X,Float:Y,Float:Z,Float:RotX,Float:RotY,Float:RotZ)
{
        sprunk[id] = CreateObject(955,X,Y,Z,RotX,RotY,RotZ);
        GetObjectPos(sprunk[id],Rot[1][id],Rot[2][id],Rot[3][id]);
        GetObjectRot(sprunk[id],Rot[4][id],Rot[5][id],Rot[6][id]);
        return id;
}

public Sprunkend(playerid)
{
        ApplyAnimation(playerid,"VENDING","VEND_Drink_P",3.0,0,0,0,0,0);
        TogglePlayerControllable(playerid,1);
        new Float:health;
        GetPlayerHealth(playerid,health);
        SetPlayerHealth(playerid,health+10);

}


public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z, Float:RotX, Float:RotY, Float:RotZ)
        {
        new Float:oldposx, Float:oldposy, Float:oldposz, Float:oldposrotx, Float:oldposroty, Float:oldposrotz;
        new Float:tempposx, Float:tempposy, Float:tempposz, Float:tempposrotx, Float:tempposroty, Float:tempposrotz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        GetObjectRot(playerid, oldposrotx, oldposroty, oldposrotz);
        tempposx    = (oldposx -x);
        tempposy    = (oldposy -y);
        tempposz    = (oldposz -z);
        tempposrotx = (oldposrotx -RotX);
        tempposroty = (oldposroty -RotY);
        tempposrotz = (oldposrotz -RotZ);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi) && (tempposrotx < radi) && (tempposrotx > -radi)) && ((tempposroty < radi) && (tempposroty > -radi)) && ((tempposrotz < radi) && (tempposrotz > -radi)))
        {
                return 1;
        }
        return 0;
}

IsPlayerInSphere(playerid,Float:x,Float:y,Float:z,radius)
{
   if(GetPlayerDistanceToPointEx(playerid,x,y,z) < radius){
   return 1;
}
   return 0;
}

GetPlayerDistanceToPointEx(playerid,Float:x,Float:y,Float:z)
{
   new Float:x1,Float:y1,Float:z1;
   new Float:tmpdis;
   GetPlayerPos(playerid,x1,y1,z1);
   tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)+floatpower(floatabs(floatsub(z,z1)),2));
   return floatround(tmpdis);
}