public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/drag", cmdtext, true, 10) == 0) { new float:A; new float:deltaX; new float:deltaY; new float:deltaZ; new float, float:y, float:z; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, A); deltaX=(floatsin(A)*400); deltaY=(floatcos(A)*400); SetPlayerRaceCheckpoint(playerid, 2, x+deltaX, y+deltaY, z, x+deltaX, y+deltaY, z,5); return 1; } return 0; } |
//GET X Y IN FRONT OR BEHIND---------------------------------------------------- stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYBehindPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYBehindPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYInFrontOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x + (distance * floatsin(-A,degrees)); y2 = y + (distance * floatcos(-A,degrees)); } stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A,degrees)); y2 = y - (distance * floatcos(-A,degrees)); } //------------------------------------------------------------------------------
if (strcmp("/drag", cmdtext, true, 5) == 0)//this should set a checkpoint 400m in front of player vehicle { new float:x, float:y, float:z, float:X, float:Y; GetXYInFrontOfPlayer(playerid,X,Y,400); GetPlayerPos(playerid,x,y,z); SetPlayerCheckpoint(playerid,X,Y,z,5); return 1; }
stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); }
stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); if(GetPlayerVehicleID(playerid)) GetVehicleAngelZ(GetPlayerVehicleID(playerid),A); else GetPlayerFacingAngle(playerid,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); }
//GET X Y IN FRONT OR BEHIND PLAYER--------------------------------------------- stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYBehindPlayer(playerid,&Float:x,&Float:y,Float:dis) { new float:pos[3]; new float:A; GetPlayerPos(playerid,pos[0],pos[1],pos[2]); GetPlayerFacingAngle(playerid,A); GetXYBehindPoint(pos[0],pos[1],x,y,A,dis); } //GET X Y IN FRONT/BEHIND/LEFT/RIGHT OF POINT----------------------------------- stock GetXYInFrontOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x + (distance * floatsin(-A,degrees)); y2 = y + (distance * floatcos(-A,degrees)); } stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A,degrees)); y2 = y - (distance * floatcos(-A,degrees)); } stock GetXYLeftOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A-90.0,degrees)); y2 = y - (distance * floatcos(-A-90.0,degrees)); } stock GetXYRightOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:A,Float:distance) { x2 = x - (distance * floatsin(-A+90.0,degrees)); y2 = y - (distance * floatcos(-A+90.0,degrees)); } //------------------------------------------------------------------------------ //GET X Y IN FRONT OR BEHIND OF VEHICLE----------------------------------------- stock GetXYInFrontOfVehicle(playerid,&Float:x,&Float:y,Float:dis) { new currentveh; new float:pos[3]; new float:A; currentveh = GetPlayerVehicleID(playerid); GetVehiclePos(currentveh,pos[0],pos[1],pos[2]); GetVehicleZAngle(currentveh,A); GetXYInFrontOfPoint(pos[0],pos[1],x,y,A,dis); } stock GetXYBehindVehicle(playerid,&Float:x,&Float:y,Float:dis) { new currentveh; new float:pos[3]; new float:A; currentveh = GetPlayerVehicleID(playerid); GetVehiclePos(currentveh,pos[0],pos[1],pos[2]); GetVehicleZAngle(currentveh,A); GetXYBehindPoint(pos[0],pos[1],x,y,A,dis); } //------------------------------------------------------------------------------
{ new currentveh; new float:x, float:y, float:z, float:X, float:Y; currentveh = GetPlayerVehicleID(playerid); GetXYInFrontOfVehicle(playerid,X,Y,400); GetVehiclePos(currentveh,x,y,z); SetPlayerCheckpoint(playerid,X,Y,z,10); return 1; }
public OnPlayerCommandText(playerid, cmdtext[]) //DRAG RACE--------------------------------------------------------------------- //****************************************************************************** { dcmd(drag,4, cmdtext); return 0; } dcmd_drag (playerid, params[]) //line 137 { new targetid, bet; if (sscanf(params, "ui", targetid,bet)) SendClientMessage(playerid, COLOR_RED, "Usage: /drag <playerid> <bet>"); else if (targetid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Player not found"); else if (bet > GetPlayerMoney(playerid)) SendClientMessage(playerid, COLOR_RED, "Insufficient Funds"); else { new str[128]; new name[32]; GetPlayerName(playerid,name,32); format(str,sizeof(str),"%s has challenged you to a 1/4 mile race betting %i$! Do you accept?(/drag0)",name,bet); SendClientMessage(targetid,COLOR_YELLOW,str); SetChallengerValue(playerid); SetChallengerVehValue(playerid); SetStakesValue(playerid); } return 1; } //DRAG ACCEPT------------------------------------------------------------------- {//line 179 dcmd(drag0,5,cmdtext);//line 180 return 0;//line 181 } dcmd_drag0 (playerid, params[]) { #pragma unused params new currentveh; new float:x, float:y, float:z, float:X, float:Y, float:a, float:b, float:c, float:d; currentveh = GetPlayerVehicleID(playerid); GetXYInFrontOfVehicle(challenger,X,Y,400); GetXYLeftOfVehicle(challenger[playerid],a,b,3); GetXYLeftOfVehicle(challenger[playerid],c,d,3); GetVehiclePos(challengerveh,x,y,z); SetPlayerRaceCheckpoint(challenger[playerid],1,X,Y,z,X,Y,z,10); SetPlayerRaceCheckpoint(playerid,1,X,Y,z,X,Y,z,10); SetVehiclePos(challengerveh[playerid],a,b,z); SetVehiclePos(currentveh,c,d,z); }
dcmd(drag0,5,cmdtext)
//PUBLIC ARRAYS & VARS---------------------------------------------------------- new targetid, bet; new challenger[MAX_PLAYERS]; SetChallengerValue(playerid, value) { challenger[targetid] = playerid; } new challengerveh[MAX_PLAYERS]; SetChallengerVehValue(playerid, value) { challengerveh[targetid] = GetPlayerVehicleID(playerid); } new stakes[MAX_PLAYERS]; SetStakesValue(playerid, value) { stakes[targetid] = bet; }