Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define COLOR 0x00FF00FF
- #define RED 0xFF0000FF
- #define DISTANCESHOT 300
- #define EXPORADIUS 7
- #define MOVESPEED 70
- #define TIMERTIME 300
- stock SetObjectFaceToPlayer(objectid,playerid)
- {
- new Float:X[2], Float:Y[2], Float:Z;
- new Float:Angle;
- GetObjectPos(objectid, X[0], Y[0], Z);
- GetPlayerPos(playerid, X[1], Y[1], Z);
- if(X[0] > X[1] && Y[0] > Y[1]) Angle = floatabs(atan2(floatsub(X[1], X[0]), floatsub(Y[1], Y[0])));
- if(X[0] > X[1] && Y[0] <= Y[1]) Angle = floatabs(atan2(floatsub(Y[0], Y[1]), floatsub(X[1], X[0]))) + 270.0;
- if(X[0] <= X[1] && Y[0] > Y[1]) Angle = floatabs(atan2(floatsub(Y[1], Y[0]), floatsub(X[0], X[1]))) + 90.0;
- if(X[0] <= X[1] && Y[0] <= Y[1]) Angle = floatabs(atan2(floatsub(X[0], X[1]), floatsub(Y[0], Y[1]))) + 180.0;
- SetObjectRot(objectid,0,0,Angle);
- return 1;
- }
- stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- if (IsPlayerInAnyVehicle(playerid))
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- else
- GetPlayerFacingAngle(playerid, a);
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- return a;
- }
- new flare[MAX_PLAYERS];
- new launcher[MAX_OBJECTS];
- new placed[MAX_OBJECTS];
- new placinglnchr[MAX_PLAYERS];
- new timer[MAX_PLAYERS];
- forward launch(playerid);
- forward flarekill(flare2,playerid);
- public OnPlayerConnect(playerid){
- placinglnchr[playerid] = -1;
- timer[playerid] = SetTimerEx("launch",TIMERTIME,1,"i",playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid){
- KillTimer(timer[playerid]);
- return 1;
- }
- public OnPlayerDeath(playerid){
- DestroyObject(flare[playerid]);
- return 1;
- }
- public OnFilterScriptInit(){
- print("In-game launcher creator by Kurence loaded");
- for(new i;i<MAX_OBJECTS;i++) launcher[i] = -1;
- }
- public OnPlayerCommandText(playerid,cmdtext[]){
- if(strcmp("/addlauncher",cmdtext,true) == 0){
- if(placinglnchr[playerid] != -1){
- new string[100];
- format(string,sizeof(string),"Launcher created, his ID: %d",placinglnchr[playerid]);
- SendClientMessage(playerid,COLOR,string);
- DestroyObject(launcher[placinglnchr[playerid]]);
- new Float:X,Float:Y,Float:Z,Float:angle;
- GetPlayerPos(playerid,X,Y,Z);
- GetXYInFrontOfPlayer(playerid,X,Y,10);
- GetPlayerFacingAngle(playerid,angle);
- launcher[placinglnchr[playerid]] = CreateObject(3267,X,Y,Z,0,0,angle);
- placed[placinglnchr[playerid]] = 1;
- placinglnchr[playerid] = -1;
- return 1;
- }
- new Float:X,Float:Y,Float:Z;
- GetPlayerPos(playerid,X,Y,Z);
- GetXYInFrontOfPlayer(playerid,X,Y,10);
- for(new i;i<MAX_OBJECTS;i++){
- if(launcher[i] == -1){
- launcher[i] = CreateObject(3267,X,Y,Z,0,0,0);
- AttachObjectToPlayer(launcher[i],playerid,0,10,0,0,0,0);
- SendClientMessage(playerid,COLOR,"Place the launcher where you want it and use ''/addlauncher'' again");
- placinglnchr[playerid] = i;
- break;
- }
- }
- return 1;
- }
- if(strcmp("/dellauncher",cmdtext,true) == 0){
- if(placinglnchr[playerid] != -1) return SendClientMessage(playerid,RED,"Place that launcher first");
- for(new i;i<MAX_OBJECTS;i++){
- if(launcher[i] != -1){
- new Float:X,Float:Y,Float:Z;
- GetObjectPos(launcher[i],X,Y,Z);
- if(IsPlayerInRangeOfPoint(playerid,10,X,Y,Z)){
- DestroyObject(launcher[i]);
- launcher[i] = -1;
- }
- }
- }
- return 1;
- }
- return 0;
- }
- public launch(playerid){
- new Float:X,Float:Y,Float:Z;
- new Model = GetVehicleModel(GetPlayerVehicleID(playerid));
- if (Model == 548 || Model == 417 || Model == 557 || Model == 476 || Model == 520 || Model == 563 || Model == 553 || Model == 519 || Model == 592 || Model == 577 || Model == 497 || Model == 464 || Model == 465 || Model == 511 || Model == 512 || Model == 593 || Model == 460 || Model == 513 || Model == 425 || Model == 487 || Model == 488 || Model == 447 || Model == 469 || Model == 501){
- if(IsValidObject(flare[playerid])){
- GetObjectPos(flare[playerid],X,Y,Z);
- if(IsPlayerInRangeOfPoint(playerid,EXPORADIUS,X,Y,Z)){
- CreateExplosion(X,Y,Z,7,25);
- DestroyObject(flare[playerid]);
- }
- else{
- GetPlayerPos(playerid,X,Y,Z);
- MoveObject(flare[playerid],X,Y,Z,MOVESPEED);
- }
- return 1;
- }
- for(new i;i<MAX_OBJECTS;i++){
- if(placed[i] != 1) return 0;
- new Float:pX,Float:pY,Float:pZ;
- if(launcher[i] != -1){
- SetObjectFaceToPlayer(launcher[i],playerid);
- GetObjectPos(launcher[i],X,Y,Z);
- GetPlayerPos(playerid,pX,pY,pZ);
- if(IsPlayerInRangeOfPoint(playerid,DISTANCESHOT,X,Y,Z)){
- flare[playerid] = CreateObject(354,X,Y,Z,0,0,0);
- MoveObject(flare[playerid],pX,pY,pZ,MOVESPEED);
- SetTimerEx("flarekill",30000,0,"ii",flare[playerid],playerid);
- return 1;
- }
- }
- }
- }
- else{
- CreateExplosion(X,Y,Z,7,25);
- DestroyObject(flare[playerid]);
- }
- return 1;
- }
- public flarekill(flare2,playerid){
- new Float:X,Float:Y,Float:Z;
- GetObjectPos(flare2,X,Y,Z);
- CreateExplosion(X,Y,Z,7,25);
- DestroyObject(flare2);
- }
- public OnPlayerKeyStateChange(playerid) launch(playerid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement