Доступ к архиву

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Drift Timer

Статус
В этой теме нельзя размещать новые ответы.

Alez

Новичок
Хелп) Подскажите пожалуйста как тут выдать всем сообщение (SendClientMessageToAll) при достижении игроком дрифт очков 10000? Все перепробовал выдает 10ый Error) с меня однозначно +)

Код:
Код:
#include <a_samp> // äðèôò

#define GivePlayerMoney(%0,%1) CallRemoteFunction("CrossModGivePlayerMoney", "ii", ( %0 ), ( %1 ))
#define SetVehicleHealth(%0,%1) CallRemoteFunction("CrossModSetVehicleHealth", "if", ( %0 ), ( %1 ))

#define DRIFT_MINKAT 10.0 // äðèôò
#define DRIFT_MAXKAT 90.0 //äðèôò
#define DRIFT_SPEED 30.0 //äðèôò

//////////// äðèôò///////
#define COLOR_Label 0xFFFFFFFF
#define COLOR_LabelOut 0x00000040
#define COLOR_ValueOut 0xFFFFFF40
#define COLOR_Value 0x000000FF

#define Label_X 500
#define Value_X 500
#define TD_Y 140
/////////////////////////////////////

new DriftTimer[MAX_PLAYERS]; //äðèôò
new TimerA,TimerB,TimerC; //äðèôò

new DriftPointsNow[MAX_PLAYERS]; //äðèôò
new PlayerDriftCancellation[MAX_PLAYERS]; //äðèôò
new Float:ppos[MAX_PLAYERS][3]; //äðèôò
enum Float:Pos{ Float:sX,Float:sY,Float:sZ }; // äðèôò
new Float:SavedPos[MAX_PLAYERS][Pos]; //äðèôò

new bool:DriftMode[MAX_PLAYERS]=false; // äðèôò
new DriftBonus[MAX_PLAYERS]=1; //äðèôò
new Float:HealthInit[MAX_PLAYERS]=1000.0; //äðèôò

new Text:TDLabels[3]; // Added by Abhinav
new PlayerText:TDValueDrift[MAX_PLAYERS]; //äðèôò
new PlayerText:TDValueBonus[MAX_PLAYERS]; //äðèôò
new PlayerText:TDValueCash[MAX_PLAYERS]; //äðèôò

forward Drift(); //äðèôò
forward AngleUpdate(); //äðèôò
forward DriftExit(playerid); //äðèôò
forward CheckPlayerState(); //äðèôò
forward AutoFix(); //äðèôò

public OnFilterScriptInit(){
	TimerA=SetTimer("AngleUpdate", 200, true); //äðèôò
	TimerB=SetTimer("AutoFix", 500, true); //äðèôò
	TimerC=SetTimer("CheckPlayerState", 100, true); //äðèôò
	LoadTextDraws();
	return 1;
}

public OnFilterScriptExit(){
	KillTimer(TimerA);
	KillTimer(TimerB);
	KillTimer(TimerC);
	return 1;
}

Float:GetPlayerTheoreticAngle(i) //äðèôò
{
	new Float:sin;
	new Float:dis;
	new Float:angle2;
	new Float:x,Float:y,Float:z;
	new Float:tmp3;
	new Float:tmp4;
	new Float:MindAngle;
	
	if(IsPlayerConnected(i)){
        
		GetPlayerPos(i,x,y,z);
		
		dis = floatsqroot(floatpower(floatabs(floatsub(x,ppos[i][0])),2)+floatpower(floatabs(floatsub(y,ppos[i][1])),2));
		
		if(IsPlayerInAnyVehicle(i)){GetVehicleZAngle(GetPlayerVehicleID(i), angle2);}else{GetPlayerFacingAngle(i, angle2);}
		
		if(x>ppos[i][0]){tmp3=x-ppos[i][0];}else{tmp3=ppos[i][0]-x;}
		if(y>ppos[i][1]){tmp4=y-ppos[i][1];}else{tmp4=ppos[i][1]-y;}
		
		if(ppos[i][1]>y && ppos[i][0]>x){
			sin = asin(tmp3/dis);
			MindAngle = floatsub(floatsub(floatadd(sin, 90), floatmul(sin, 2)), -90.0);
		}
		
		if(ppos[i][1]<y && ppos[i][0]>x){
			sin = asin(tmp3/dis);
			MindAngle = floatsub(floatadd(sin, 180), 180.0);
		}
		
		if(ppos[i][1]<y && ppos[i][0]<x){
			sin = acos(tmp4/dis);
			MindAngle = floatsub(floatadd(sin, 360), floatmul(sin, 2));
		}
		
		if(ppos[i][1]>y && ppos[i][0]<x){
			sin = asin(tmp3/dis);
			MindAngle = floatadd(sin, 180);
		}
	}
	
	if(MindAngle == 0.0){return angle2;}else{return MindAngle;}
}

public DriftExit(playerid){ //äðèôò
	PlayerDriftCancellation[playerid] = 0;
	
	//////////////////äðèôò ///////////////////
	new Float:h;
	GetVehicleHealth(GetPlayerVehicleID(playerid),h);
	if(DriftPointsNow[playerid]>70 && DriftPointsNow[playerid]<10000 && h==HealthInit[playerid]){
		new money=DriftPointsNow[playerid]*DriftBonus[playerid];
		GivePlayerMoney(playerid, money);
	}
	TextDrawHideForPlayer(playerid,TDLabels[0]);
	TextDrawHideForPlayer(playerid,TDLabels[1]);
	TextDrawHideForPlayer(playerid,TDLabels[2]);
	PlayerTextDrawHide(playerid,TDValueDrift[playerid]);
	PlayerTextDrawHide(playerid,TDValueBonus[playerid]);
	PlayerTextDrawHide(playerid,TDValueCash[playerid]);
	DriftBonus[playerid]=1;
	////////////////////////////////////////////////////
	
	DriftPointsNow[playerid] = 0;
}

Float:ReturnPlayerAngle(playerid){ //äðèôò
	new Float:Ang;
	if(IsPlayerInAnyVehicle(playerid))GetVehicleZAngle(GetPlayerVehicleID(playerid), Ang); else GetPlayerFacingAngle(playerid, Ang);
	return Ang;
}

public Drift(){ //äðèôò
	new Float:Angle1, Float:Angle2, Float:BySpeed;
	new Float:Z;
	new Float:X;
	new Float:Y;
	new Float:SpeedX;
	for(new g=0;g<200;g++){
		GetPlayerPos(g, X, Y, Z);
		SpeedX = floatsqroot(floatadd(floatadd(floatpower(floatabs(floatsub(X,SavedPos[ g ][ sX ])),2),floatpower(floatabs(floatsub(Y,SavedPos[ g ][ sY ])),2)),floatpower(floatabs(floatsub(Z,SavedPos[ g ][ sZ ])),2)));
		Angle1 = ReturnPlayerAngle(g);
		Angle2 = GetPlayerTheoreticAngle(g);
		BySpeed = floatmul(SpeedX, 12);
		if(IsPlayerInAnyVehicle(g) && GetVType(GetPlayerVehicleID(g)) && floatabs(floatsub(Angle1, Angle2)) > DRIFT_MINKAT && floatabs(floatsub(Angle1, Angle2)) < DRIFT_MAXKAT && BySpeed > DRIFT_SPEED){
			if(PlayerDriftCancellation[g] > 0)KillTimer(PlayerDriftCancellation[g]);
			PlayerDriftCancellation[g] = 0;
			DriftPointsNow[g] += floatval( floatabs(floatsub(Angle1, Angle2)) * 3 * (BySpeed*0.1) )/10;
			PlayerDriftCancellation[g] = SetTimerEx("DriftExit", 3000, 0, "d", g);
		}
		
		if(DriftPointsNow[g] > 70 && DriftPointsNow[g]<10000){
			///////////// äðèôò ////////////////////
			if(DriftPointsNow[g]<2000){
				DriftBonus[g]=1;
			}
			if(DriftPointsNow[g]>=2000 && DriftPointsNow[g]<500){
				DriftBonus[g]=2;
			}
			if(DriftPointsNow[g]>=5000 && DriftPointsNow[g]<1000){
				DriftBonus[g]=3;
			}
			if(DriftPointsNow[g]>=10000 && DriftPointsNow[g]<1500){
				DriftBonus[g]=4;
			}
			if(DriftPointsNow[g]>=15000){
				DriftBonus[g]=5;
			}
			
			TextDrawShowForPlayer(g,TDLabels[0]);
			TextDrawShowForPlayer(g,TDLabels[1]);
			TextDrawShowForPlayer(g,TDLabels[2]);
			
			PlayerTextDrawShow(g,TDValueDrift[g]);
			PlayerTextDrawShow(g,TDValueBonus[g]);
			PlayerTextDrawShow(g,TDValueCash[g]);
			
			new DPs[128],DBn[128],Cash[128],csh;
			
			valstr(DPs,DriftPointsNow[g],false);
			format(DBn,sizeof(DBn),"X%i",DriftBonus[g]);
			csh=DriftPointsNow[g]*DriftBonus[g];
			format(Cash,sizeof(Cash),"$%i",csh);
			
			PlayerTextDrawSetString(g,TDValueDrift[g],DPs);
			PlayerTextDrawSetString(g,TDValueBonus[g],DBn);
			PlayerTextDrawSetString(g,TDValueCash[g],Cash);
			////////////////////////////////////////
		}
		SavedPos[ g ][ sX ] = X;
		SavedPos[ g ][ sY ] = Y;
		SavedPos[ g ][ sZ ] = Z;
	}
}

public AngleUpdate(){ //äðèôò
	for(new g=0;g<=MAX_PLAYERS;g++){
		new Float:x, Float:y, Float:z;
		if(IsPlayerInAnyVehicle(g))GetVehiclePos(GetPlayerVehicleID(g), x, y, z); else GetPlayerPos(g, x, y, z);
		ppos[g][0] = x;
		ppos[g][1] = y;
		ppos[g][2] = z;
	}
}

floatval(Float:val){ //äðèôò
	new str[256];
	format(str, 256, "%.0f", val);
	return todec(str);
}

todec(str[]){ //äðèôò
	return strval(str);
}

LoadTextDraws(){ //äðèôò
	TDLabels[0]=TextDrawCreate(Label_X,TD_Y,"Drift Score");
	TextDrawColor(TDLabels[0],COLOR_Label);
	TextDrawSetShadow(TDLabels[0],0);
	TextDrawSetOutline(TDLabels[0],1);
	TextDrawLetterSize(TDLabels[0],0.5,2);
	TextDrawBackgroundColor(TDLabels[0],COLOR_LabelOut);
	TextDrawFont(TDLabels[0],1);
	
	TDLabels[1]=TextDrawCreate(Label_X,TD_Y+50,"Drift Bonus");
	TextDrawColor(TDLabels[1],COLOR_Label);
	TextDrawSetShadow(TDLabels[1],0);
	TextDrawSetOutline(TDLabels[1],1);
	TextDrawLetterSize(TDLabels[1],0.5,2);
	TextDrawBackgroundColor(TDLabels[1],COLOR_LabelOut);
	TextDrawFont(TDLabels[1],1);
	
	TDLabels[2]=TextDrawCreate(Label_X,TD_Y+100,"Drift Cash");
	TextDrawColor(TDLabels[2],COLOR_Label);
	TextDrawSetShadow(TDLabels[2],0);
	TextDrawSetOutline(TDLabels[2],1);
	TextDrawLetterSize(TDLabels[2],0.5,2);
	TextDrawBackgroundColor(TDLabels[2],COLOR_LabelOut);
	TextDrawFont(TDLabels[2],1);
	return 1;
}
public OnPlayerConnect(playerid){
	TDValueDrift[playerid]=CreatePlayerTextDraw(playerid,Value_X,TD_Y+20,"Score - 0");
	PlayerTextDrawColor(playerid,TDValueDrift[playerid],COLOR_Value);
	PlayerTextDrawSetShadow(playerid,TDValueDrift[playerid],0);
	PlayerTextDrawSetOutline(playerid,TDValueDrift[playerid],1);
	PlayerTextDrawLetterSize(playerid,TDValueDrift[playerid],0.5,2);
	PlayerTextDrawBackgroundColor(playerid,TDValueDrift[playerid],COLOR_ValueOut);
	PlayerTextDrawFont(playerid,TDValueDrift[playerid],3);
	
	TDValueBonus[playerid]=CreatePlayerTextDraw(playerid,Value_X,TD_Y+70,"X1");
	PlayerTextDrawColor(playerid,TDValueBonus[playerid],COLOR_Value);
	PlayerTextDrawSetShadow(playerid,TDValueBonus[playerid],0);
	PlayerTextDrawSetOutline(playerid,TDValueBonus[playerid],1);
	PlayerTextDrawLetterSize(playerid,TDValueBonus[playerid],0.5,2);
	PlayerTextDrawBackgroundColor(playerid,TDValueBonus[playerid],COLOR_ValueOut);
	PlayerTextDrawFont(playerid,TDValueBonus[playerid],3);
	
	TDValueCash[playerid]=CreatePlayerTextDraw(playerid,Value_X,TD_Y+120,"$0");
	PlayerTextDrawColor(playerid,TDValueCash[playerid],COLOR_Value);
	PlayerTextDrawSetShadow(playerid,TDValueCash[playerid],0);
	PlayerTextDrawSetOutline(playerid,TDValueCash[playerid],1);
	PlayerTextDrawLetterSize(playerid,TDValueCash[playerid],0.5,2);
	PlayerTextDrawBackgroundColor(playerid,TDValueCash[playerid],COLOR_ValueOut);
	PlayerTextDrawFont(playerid,TDValueCash[playerid],3);
	
}
public CheckPlayerState(){ //äðèôò
	new i,cs;
	for(i=0;i<=MAX_PLAYERS;i++){
	    cs=GetPlayerState(i);
	    if(DriftMode[i] && cs==PLAYER_STATE_DRIVER && DriftPointsNow[i]>70){
	        new Float:h;
	        GetVehicleHealth(GetPlayerVehicleID(i),h);
	        if(h<HealthInit[i]){
	        	KillTimer(DriftTimer[i]);
	        	DriftExit(i);
	        	GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~n~~r~Boom",800,5);
	        	DriftMode[i]=false;
			}
		}
	    if(cs==PLAYER_STATE_DRIVER && DriftMode[i]==false){
	        if(GetVType(GetPlayerVehicleID(i))){
		        DriftMode[i]=true;
		        GetVehicleHealth(GetPlayerVehicleID(i),HealthInit[i]);
		        DriftTimer[i]=SetTimerEx("Drift", 200, true, "i", i);
			}
		}
		else if(cs!=PLAYER_STATE_DRIVER && DriftMode[i]==true){
		    KillTimer(DriftTimer[i]);
		    DriftMode[i]=false;
		}
		else{}
	}
	return 1;
}
GetVType(vid){ //äðèôò
	
	new Convertibles[4]={480, 533, 439, 555};
	new Industrial[26]={499, 422, 482, 498, 609, 524, 578, 455, 403, 414, 582, 443, 514, 413, 515, 440, 543, 605, 459, 531, 408, 552, 478, 456, 554};
	new LowRider[8]={536, 575, 534, 567, 535, 566, 576, 412};
	new OffRoad[13]={568, 424, 573, 579, 400, 500, 444, 556, 557, 470, 489, 505, 595};
	new Service[19]={416, 433, 431, 438, 437, 523, 427, 490, 528, 407, 544, 596, 596, 597, 598, 599, 432, 601, 420};
	new Saloon[35]={445, 504, 401, 518, 527, 542, 507, 562, 585, 419, 526, 604, 466, 492, 474, 546, 517, 410, 551, 516, 467, 600, 426, 436, 547, 405, 580, 560, 550, 549, 540, 491, 529, 421};
	new Sports[20]={602, 429, 496, 402, 541, 415, 589, 587, 565, 494, 502, 503, 411, 559, 603, 475, 506, 451, 558, 477};
	new Wagons[5]={418, 404, 479, 458, 561};
	
	new modelid=GetVehicleModel(vid);
	new i;
	for(i=0;i<3;i++){
		if(Convertibles[i]==modelid) return 1;
	}
	for(i=0;i<25;i++){
		if(Industrial[i]==modelid) return 1;
	}
	for(i=0;i<7;i++){
		if(LowRider[i]==modelid) return 1;
	}
	for(i=0;i<12;i++){
		if(OffRoad[i]==modelid) return 1;
	}
	for(i=0;i<19;i++){
		if(Service[i]==modelid) return 1;
	}
	for(i=0;i<35;i++){
		if(Saloon[i]==modelid) return 1;
	}
	for(i=0;i<20;i++){
		if(Sports[i]==modelid) return 1;
	}
	for(i=0;i<5;i++){
		if(Wagons[i]==modelid) return 1;
	}
	return 0;
}
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу