21.02.2012, 17:41
Hey!
I need your help again, I have a Drift Points Counter and I need to make a variable to store all drift points for each player.
I want to do something that save and load all drift points, the save and load it's not a problem, i have a problem with the variable..
This is the fs.
I need your help again, I have a Drift Points Counter and I need to make a variable to store all drift points for each player.
I want to do something that save and load all drift points, the save and load it's not a problem, i have a problem with the variable..
This is the fs.
Код:
#include < a_samp > #include < zcmd > #define MaximumPlayers 150 #pragma tabsize 0 new bool:DriftingState[ MaximumPlayers ]; new bool:ScoreState[ MaximumPlayers ]; new Float:TDirection, Float:CDirection, Float:DriftAngle, Float:speed; new Score[ MaximumPlayers ]; new string[64]; new Text:DrawSpeedBonus[ MaximumPlayers ]; new Text:DrawAngleBonus[ MaximumPlayers ]; new Text:DrawScore[ MaximumPlayers ]; new Text:DrawLastScore[ MaximumPlayers ]; new Text:DrawBestScore[ MaximumPlayers ]; public OnPlayerConnect(playerid) { DrawScore[playerid] = TextDrawCreate(484.000000, 102.000000, "Points: 0"); TextDrawBackgroundColor(DrawScore[playerid], 255); TextDrawFont(DrawScore[playerid], 1); TextDrawLetterSize(DrawScore[playerid], 0.500000, 1.000000); TextDrawColor(DrawScore[playerid], -16776961); TextDrawSetOutline(DrawScore[playerid], 1); TextDrawSetProportional(DrawScore[playerid], 1); DrawBestScore[playerid] = TextDrawCreate(484.000000, 122.000000, "Best: 0"); TextDrawBackgroundColor(DrawBestScore[playerid], 255); TextDrawFont(DrawBestScore[playerid], 1); TextDrawLetterSize(DrawBestScore[playerid], 0.500000, 1.000000); TextDrawColor(DrawBestScore[playerid], -16776961); TextDrawSetOutline(DrawBestScore[playerid], 1); TextDrawSetProportional(DrawBestScore[playerid], 1); DrawLastScore[playerid] = TextDrawCreate(485.000000, 112.000000, "Last: 0"); TextDrawBackgroundColor(DrawLastScore[playerid], 255); TextDrawFont(DrawLastScore[playerid], 1); TextDrawLetterSize(DrawLastScore[playerid], 0.500000, 1.000000); TextDrawColor(DrawLastScore[playerid], -16776961); TextDrawSetOutline(DrawLastScore[playerid], 1); TextDrawSetProportional(DrawLastScore[playerid], 1); DrawSpeedBonus[playerid] = TextDrawCreate(606.000000, 133.000000, "Speed Bonus!"); TextDrawAlignment(DrawSpeedBonus[playerid], 3); TextDrawBackgroundColor(DrawSpeedBonus[playerid], 255); TextDrawFont(DrawSpeedBonus[playerid], 1); TextDrawLetterSize(DrawSpeedBonus[playerid], 0.500000, 1.000000); TextDrawColor(DrawSpeedBonus[playerid], 16711935); TextDrawSetOutline(DrawSpeedBonus[playerid], 1); TextDrawSetProportional(DrawSpeedBonus[playerid], 1); DrawAngleBonus[playerid] = TextDrawCreate(606.000000, 143.000000, "Angle Bonus"); TextDrawAlignment(DrawAngleBonus[playerid], 3); TextDrawBackgroundColor(DrawAngleBonus[playerid], 255); TextDrawFont(DrawAngleBonus[playerid], 1); TextDrawLetterSize(DrawAngleBonus[playerid], 0.500000, 1.000000); TextDrawColor(DrawAngleBonus[playerid], 16711935); TextDrawSetOutline(DrawAngleBonus[playerid], 1); TextDrawSetProportional(DrawAngleBonus[playerid], 1); } CMD:drift( playerid, params[ ] ) { if ((DriftingState[playerid] == false) && (IsPlayerInAnyVehicle(playerid)==1)) { DriftingState[playerid]=true; SendClientMessage(playerid, 0xFFFFFF, "DriftMode - ON"); TextDrawShowForPlayer(playerid,DrawScore[playerid]); TextDrawShowForPlayer(playerid,DrawLastScore[playerid]); TextDrawShowForPlayer(playerid,DrawBestScore[playerid]); } else if (DriftingState[playerid] == true) { CancelDrifting(playerid); SendClientMessage(playerid, 0xFFFFFF, "DriftMode - OFF"); } if (IsPlayerInAnyVehicle(playerid)==0) { SendClientMessage(playerid, 0xFFFFFF, "You need to be in a vehicle."); } return 1; } public OnPlayerUpdate(playerid) { if (DriftingState[playerid] == true) { Drifting(playerid); } return 1; } forward Drifting(playerid); public Drifting(playerid) { new Float:x, Float:y, Float:z, vid; vid = GetPlayerVehicleID(playerid); GetVehicleVelocity(vid, x, y, z); speed = floatpower(x*x+y*y, 0.5); if (speed > 0.2) { if (x<0) { if(y>0) { TDirection = atan(floatabs(x/y)); } else if (y<=0) { TDirection = atan(y/x) + 90; } } else if (x>0) { if(y<0) { TDirection = atan(floatabs(x/y)) + 180; } else if (y>=0) { TDirection = atan(y/x) + 270; } } else if (x==0) { if (y>0) { TDirection = 0; } else if (y<0) { TDirection = 180; } } GetVehicleZAngle( vid, CDirection ); DriftAngle = floatabs( TDirection - CDirection ); if ( ( 15 < DriftAngle < 80 ) || ( 280 < DriftAngle < 345 ) ) { ScoreState[ playerid ] = true; Score[playerid]++; if ( ( 25 < DriftAngle < 70 ) || ( 290 < DriftAngle < 335 ) ) { Score[ playerid ]++; if ( ( 35 < DriftAngle < 45 ) || ( 315 < DriftAngle < 325 ) ) { Score[ playerid ]++; SetPVarInt( playerid, "AngleBonus", GetPVarInt( playerid, "AngleBonus" )+1 ); format( string, sizeof( string ), "Angle Bonus + %d !", GetPVarInt( playerid, "AngleBonus") ); TextDrawSetString( DrawAngleBonus[ playerid ], string ); TextDrawShowForPlayer( playerid, DrawAngleBonus[playerid ] ); } } if ( speed > 0.6 ) { Score[ playerid ]++; SetPVarInt( playerid, "SpeedBonus", GetPVarInt( playerid, "SpeedBonus") +1); format( string, sizeof( string ), "Speed Bonus + %d !", GetPVarInt( playerid, "SpeedBonus") ); TextDrawSetString( DrawSpeedBonus[ playerid ], string ); TextDrawShowForPlayer( playerid, DrawSpeedBonus[ playerid ] ); } format(string, sizeof(string), "Points: %d", Score[playerid]); TextDrawSetString(DrawScore[playerid], string); } /*When the player stops drifting*/ else if (Score[playerid]>0) { if (ScoreState[playerid] == true) { if (Score[playerid] > GetPVarInt(playerid, "MaxScore")) { SetPVarInt(playerid, "MaxScore", Score[playerid]); if (Score[playerid] > GetPVarInt(playerid, "AbsMaxScore")) { SetPVarInt(playerid, "AbsMaxScore", Score[playerid]); format(string,sizeof(string),"Best: %d",GetPVarInt(playerid,"AbsMaxScore")); TextDrawSetString(DrawBestScore[playerid], string); //Comment this line if you want to disable score updating(under TAB) } else { format(string,sizeof(string),"Last: %d",Score[playerid]); TextDrawSetString(DrawLastScore[playerid], string); } } else { format(string,sizeof(string),"Last: %d",Score[playerid]); TextDrawSetString(DrawLastScore[playerid], string); if (Score[playerid] > 70) //comment this bracket section if you don't want NOS/fixing with scoring (for example, when you have your own autofix) { RepairVehicle(vid); SetVehicleHealth(vid, 1000); AddVehicleComponent(vid, 1009); //2x nos } } ScoreState[playerid] = false; } TextDrawHideForPlayer(playerid, DrawSpeedBonus[playerid]); SetPVarInt(playerid, "SpeedBonus", 0); TextDrawHideForPlayer(playerid, DrawAngleBonus[playerid]); SetPVarInt(playerid, "AngleBonus", 0); Score[playerid]--; format(string, sizeof(string), "Points: %d", Score[playerid]); TextDrawSetString(DrawScore[playerid], string); } } else if (Score[playerid] > 0) { if (Score[playerid] > GetPVarInt(playerid, "AbsMaxScore")) { SetPVarInt(playerid, "AbsMaxScore", Score[playerid]); format(string,sizeof(string),"Best drift: %d",Score[playerid]); TextDrawSetString(DrawBestScore[playerid], string); } format(string,sizeof(string),"Last: %d",Score[playerid]); TextDrawSetString(DrawLastScore[playerid], string); DriftRewards(vid, Score[playerid]); Score[playerid] = 0; TextDrawSetString(DrawScore[playerid], "Points: 0"); TextDrawHideForPlayer(playerid, DrawSpeedBonus[playerid]); SetPVarInt(playerid, "SpeedBonus", 0); TextDrawHideForPlayer(playerid, DrawAngleBonus[playerid]); SetPVarInt(playerid, "AngleBonus", 0); } } CancelDrifting(playerid) { DriftingState[playerid] = false; ScoreState[playerid] = false; Score[playerid] = 0; SetPVarInt(playerid, "MaxScore", 0); SetPVarInt(playerid, "SpeedBonus", 0); SetPVarInt(playerid, "AngleBonus", 0); TextDrawHideForPlayer(playerid,DrawScore[playerid]); TextDrawHideForPlayer(playerid,DrawBestScore[playerid]); TextDrawHideForPlayer(playerid,DrawLastScore[playerid]); TextDrawHideForPlayer(playerid, DrawSpeedBonus[playerid]); TextDrawHideForPlayer(playerid, DrawAngleBonus[playerid]); return 1; } DriftRewards(vid, RewardSize) { if (GetVehicleModel(vid) == 560) //For sultan { SultanRewards(vid, RewardSize); } else if (GetVehicleModel(vid) == 562) //For elegy { ElegyRewards(vid, RewardSize); } else { GenericRewards(vid, RewardSize); } } SultanRewards(vid, RewardSize) { if (RewardSize>20) { if (RewardSize>40) { if (RewardSize > 70) { RepairVehicle(vid); SetVehicleHealth(vid, 1000); AddVehicleComponent(vid, 1009); //2x nos if (RewardSize>80) { if (RewardSize>100) { ChangeVehicleColor(vid, 151, 166); //bright red } } } } } } ElegyRewards(vid, RewardSize) { if (RewardSize>50) { if (RewardSize > 70) { RepairVehicle(vid); SetVehicleHealth(vid, 1000); AddVehicleComponent(vid, 1009); //2x nos if (RewardSize>100) { if (RewardSize>150) { if (RewardSize>200) { ChangeVehicleColor(vid, 151, 166); //bright red } } } } } } GenericRewards(vid, RewardSize) { if (RewardSize>20) { AddVehicleComponent(vid, 1074); if (RewardSize>70) { AddVehicleComponent(vid, 1009); AddVehicleComponent(vid, 1011); if (RewardSize>80) { AddVehicleComponent(vid, 1085); ChangeVehicleColor(vid, 151, 166); } } } } public OnPlayerExitVehicle(playerid, vehicleid) { if (DriftingState[playerid] == true) { CancelDrifting(playerid); SendClientMessage(playerid, 0xFFAAFFAA, "Drifting mode is OFF. You can't drift without a vehicle!"); } return 1; } public OnVehicleDamageStatusUpdate(vehicleid, playerid) { if (DriftingState[playerid] == true) { new a,b,c,d; GetVehicleDamageStatus(vehicleid, a,b,c,d); if (a || b || c || d == 1) { Score[playerid] = 0; TextDrawHideForPlayer(playerid, DrawSpeedBonus[playerid]); SetPVarInt(playerid, "SpeedBonus", 0); TextDrawHideForPlayer(playerid, DrawAngleBonus[playerid]); SetPVarInt(playerid, "AngleBonus", 0); TextDrawSetString(DrawScore[playerid], "This drift: 0"); } } return 1; } public OnPlayerDeath(playerid, killerid, reason) { if (DriftingState[playerid] == true) { CancelDrifting(playerid); SendClientMessage(playerid, 0xFFAAFFAA, "We don't want no dead people drifting 'round these parts"); } return 1; } public OnPlayerDisconnect(playerid, reason) { CancelDrifting(playerid); SetPVarInt(playerid, "AbsMaxScore", 0); TextDrawHideForAll(DrawScore[playerid]); TextDrawDestroy(DrawScore[playerid]); TextDrawHideForAll(DrawBestScore[playerid]); TextDrawDestroy(DrawBestScore[playerid]); TextDrawHideForAll(DrawLastScore[playerid]); TextDrawDestroy(DrawLastScore[playerid]); TextDrawHideForAll(DrawAngleBonus[playerid]); TextDrawDestroy(DrawAngleBonus[playerid]); TextDrawHideForAll(DrawSpeedBonus[playerid]); TextDrawDestroy(DrawSpeedBonus[playerid]); return 1; }