Help "AttachObjectToVehicle"
#1

Typing /nrgmod ,It does not work
nrgmod Edit from grider https://sampforum.blast.hk/showthread.php?tid=328072
PHP код:
#include <a_samp>
new nrg[MAX_PLAYERS][7];
public 
OnFilterScriptInit() return print("[FS]NRG Mod Loader!");
public 
OnFilterScriptExit() {
    for(new 
i=0MAX_PLAYERS+1i++){
        if(
nrg[i][0]){
            
DestroyObject(nrg[i][0]);
            
DestroyObject(nrg[i][1]);
            
DestroyObject(nrg[i][2]);
            
DestroyObject(nrg[i][3]);
            
RemovePlayerAttachedObject(i3);
            
nrg[i][0] = 0;
        }
    }
    return print(
"[FS]Ghostrider Unloaded!");
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strcmp(cmdtext"/nrgmod"true))
    {
          if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid0xFF0000AA"He Thong: Ban phai o trong chiec xe NRG-500!");
          if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid0xFF0000AA"He Thong: Ban phai la nguoi dieu khien chiec xe!");
          if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 522) return SendClientMessage(playerid0xFF0000AA"He Thong: Ban phai o trong chiec xe NRG-500 !");
        if(
nrg[playerid][0] == 0)
        {
            
DestroyObject(nrg[playerid][0]);
            
DestroyObject(nrg[playerid][1]);
            
DestroyObject(nrg[playerid][2]);
            
DestroyObject(nrg[playerid][3]);
            
RemovePlayerAttachedObject(playerid3);
            
nrg[playerid][0] = 0;
            return 
1;
        }
        new 
Float:vh;
        
GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(
vh 250) return
          
nrg[playerid][0] = CreateObject(3620.00.00.00.00.0256.0);
          
nrg[playerid][1] = CreateObject(3590.00.00.00.00.0256.0);
          
nrg[playerid][2] = CreateObject(3590.00.00.00.00.0256.0);
          
nrg[playerid][3] = CreateObject(12540.00.00.00.00.0256.0);
          
nrg[playerid][4] = CreateObject(9540.00.00.00.00.0256.0);
          
nrg[playerid][5] = CreateObject(15500.00.00.00.00.0256.0);
          
nrg[playerid][6] = CreateObject(15500.00.00.00.00.0256.0);
          
AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.060800.670800.589390.0000030.0000095.28001);
          
AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.282940.553060.018100.000000.0000090.24004);
          
AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.194300.528300.018100.000000.0000090.24000);
          
AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.001011.788770.352950.000000.000000.00000);
          
AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.000000.862300.0760070.000000.00000, -3.54000);
          
AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.597190.170330.000000.00000, -113.81998);
          
AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.632700.170300.000000.000000.00000);
          
ChangeVehicleColor(GetPlayerVehicleID(playerid), 00);
          return 
1;
    }
    return 
0;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT){
        if(
nrg[playerid][0]){
            
DestroyObject(nrg[playerid][0]);
            
DestroyObject(nrg[playerid][1]);
            
DestroyObject(nrg[playerid][2]);
            
DestroyObject(nrg[playerid][3]);
            
RemovePlayerAttachedObject(playerid3);
            
nrg[playerid][0] = 0;
        }
    }
    if(
oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_WASTED){
        if(
nrg[playerid][0]){
            
DestroyObject(nrg[playerid][0]);
            
DestroyObject(nrg[playerid][1]);
            
DestroyObject(nrg[playerid][2]);
            
DestroyObject(nrg[playerid][3]);
            
RemovePlayerAttachedObject(playerid3);
            
nrg[playerid][0] = 0;
        }
    }
    if(
oldstate == PLAYER_STATE_DRIVER)
    {
        if(
nrg[playerid][0])
        {
            
DestroyObject(nrg[playerid][0]);
            
DestroyObject(nrg[playerid][1]);
            
DestroyObject(nrg[playerid][2]);
            
DestroyObject(nrg[playerid][3]);
            
RemovePlayerAttachedObject(playerid3);
            
nrg[playerid][0] = 0;
        }
    }
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(!
IsPlayerInAnyVehicle(playerid)) return 0;
          if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 0;
          if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 463) return 0;
        new 
Float:vh;
        
GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(
vh 250) return
          
nrg[playerid][0] = CreateObject(3620.00.00.00.00.0256.0);
          
nrg[playerid][1] = CreateObject(3590.00.00.00.00.0256.0);
          
nrg[playerid][2] = CreateObject(3590.00.00.00.00.0256.0);
          
nrg[playerid][3] = CreateObject(12540.00.00.00.00.0256.0);
          
nrg[playerid][4] = CreateObject(9540.00.00.00.00.0256.0);
          
nrg[playerid][5] = CreateObject(15500.00.00.00.00.0256.0);
          
nrg[playerid][6] = CreateObject(15500.00.00.00.00.0256.0);
          
AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.060800.670800.589390.0000030.0000095.28001);
          
AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.282940.553060.018100.000000.0000090.24004);
          
AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.194300.528300.018100.000000.0000090.24000);
          
AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.001011.788770.352950.000000.000000.00000);
          
AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.000000.862300.0760070.000000.00000, -3.54000);
          
AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.597190.170330.000000.00000, -113.81998);
          
AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.632700.170300.000000.000000.00000);
          
ChangeVehicleColor(GetPlayerVehicleID(playerid), 00);
    }
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
nrg[playerid][0] = 0;
    
nrg[playerid][1] = 0;
    
nrg[playerid][2] = 0;
}
public 
OnPlayerDisconnect(playeridreason)
{
   if(
nrg[playerid][0]){
        
DestroyObject(nrg[playerid][0]);
        
DestroyObject(nrg[playerid][1]);
        
DestroyObject(nrg[playerid][2]);
        
DestroyObject(nrg[playerid][3]);
        
RemovePlayerAttachedObject(playerid3);
        
nrg[playerid][0] = 0;
    }

Reply
#2

help me
Reply
#3

if 250 is greater then the vehicle health?
pawn Код:
if(vh < 250) return
Reply
#4

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
if 250 is greater then the vehicle health?
pawn Код:
if(vh < 250) return
I still do not really get it

You can rewrite fs , help me?
Reply
#5

try this
pawn Код:
#include <a_samp>
new nrg[MAX_PLAYERS][7];
public OnFilterScriptInit() return print("[FS]NRG Mod Loader!");
public OnFilterScriptExit() {
    for(new i=0; i < MAX_PLAYERS+1; i++){
        if(nrg[i][0]){
            DestroyObject(nrg[i][0]);
            DestroyObject(nrg[i][1]);
            DestroyObject(nrg[i][2]);
            DestroyObject(nrg[i][3]);
            RemovePlayerAttachedObject(i, 3);
            nrg[i][0] = 0;
        }
    }
    return print("[FS]Ghostrider Unloaded!");
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/nrgmod", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500!");
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai la nguoi dieu khien chiec xe!");
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 522) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500 !");
        if(nrg[playerid][0] == 0)
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
            return 1;
        }
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0; // not enough health
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_WASTED){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        if(nrg[playerid][0])
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return 0;
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 0;
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 463) return 0;
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0;
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    nrg[playerid][0] = 0;
    nrg[playerid][1] = 0;
    nrg[playerid][2] = 0;
}

public OnPlayerDisconnect(playerid, reason)
{
   if(nrg[playerid][0]){
        DestroyObject(nrg[playerid][0]);
        DestroyObject(nrg[playerid][1]);
        DestroyObject(nrg[playerid][2]);
        DestroyObject(nrg[playerid][3]);
        RemovePlayerAttachedObject(playerid, 3);
        nrg[playerid][0] = 0;
    }
}
what yours was doing was
pawn Код:
if(vh < 250) return nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
then it would exit out of the function
Reply
#6

Maybe .. the positions Are wrong
Reply
#7

Not work .

Reply
#8

deleted line 33 return 1; also that should do it,would of been exiting there when the player has no object ids yet
pawn Код:
#include <a_samp>
new nrg[MAX_PLAYERS][7];
public OnFilterScriptInit() return print("[FS]NRG Mod Loader!");
public OnFilterScriptExit() {
    for(new i=0; i < MAX_PLAYERS+1; i++){
        if(nrg[i][0]){
            DestroyObject(nrg[i][0]);
            DestroyObject(nrg[i][1]);
            DestroyObject(nrg[i][2]);
            DestroyObject(nrg[i][3]);
            RemovePlayerAttachedObject(i, 3);
            nrg[i][0] = 0;
        }
    }
    return print("[FS]Ghostrider Unloaded!");
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/nrgmod", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500!");
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai la nguoi dieu khien chiec xe!");
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 522) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500 !");
        if(nrg[playerid][0] == 0)
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0; // not enough health
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_WASTED){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        if(nrg[playerid][0])
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return 0;
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 0;
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 463) return 0;
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0; // not enough health
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    nrg[playerid][0] = 0;
    nrg[playerid][1] = 0;
    nrg[playerid][2] = 0;
}

public OnPlayerDisconnect(playerid, reason)
{
   if(nrg[playerid][0]){
        DestroyObject(nrg[playerid][0]);
        DestroyObject(nrg[playerid][1]);
        DestroyObject(nrg[playerid][2]);
        DestroyObject(nrg[playerid][3]);
        RemovePlayerAttachedObject(playerid, 3);
        nrg[playerid][0] = 0;
    }
}
Reply
#9

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
deleted line 33 return 1; also that should do it,would of been exiting there when the player has no object ids yet
pawn Код:
#include <a_samp>
new nrg[MAX_PLAYERS][7];
public OnFilterScriptInit() return print("[FS]NRG Mod Loader!");
public OnFilterScriptExit() {
    for(new i=0; i < MAX_PLAYERS+1; i++){
        if(nrg[i][0]){
            DestroyObject(nrg[i][0]);
            DestroyObject(nrg[i][1]);
            DestroyObject(nrg[i][2]);
            DestroyObject(nrg[i][3]);
            RemovePlayerAttachedObject(i, 3);
            nrg[i][0] = 0;
        }
    }
    return print("[FS]Ghostrider Unloaded!");
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/nrgmod", true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500!");
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai la nguoi dieu khien chiec xe!");
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 522) return SendClientMessage(playerid, 0xFF0000AA, "He Thong: Ban phai o trong chiec xe NRG-500 !");
        if(nrg[playerid][0] == 0)
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0; // not enough health
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 0;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_WASTED){
        if(nrg[playerid][0]){
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        if(nrg[playerid][0])
        {
            DestroyObject(nrg[playerid][0]);
            DestroyObject(nrg[playerid][1]);
            DestroyObject(nrg[playerid][2]);
            DestroyObject(nrg[playerid][3]);
            RemovePlayerAttachedObject(playerid, 3);
            nrg[playerid][0] = 0;
        }
    }
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return 0;
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 0;
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 463) return 0;
        new Float:vh;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vh);
        if(vh < 250) return 0; // not enough health
        else {
            nrg[playerid][0] = CreateObject(362, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][1] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][2] = CreateObject(359, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][3] = CreateObject(1254, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][4] = CreateObject(954, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][5] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            nrg[playerid][6] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 256.0);
            AttachObjectToVehicle(nrg[playerid][0], GetPlayerVehicleID(playerid), 0.06080, 0.67080, 0.58939, 0.00000, 30.00000, 95.28001);
            AttachObjectToVehicle(nrg[playerid][1], GetPlayerVehicleID(playerid), 0.28294, 0.55306, 0.01810, 0.00000, 0.00000, 90.24004);
            AttachObjectToVehicle(nrg[playerid][2], GetPlayerVehicleID(playerid), -0.19430, 0.52830, 0.01810, 0.00000, 0.00000, 90.24000);
            AttachObjectToVehicle(nrg[playerid][3], GetPlayerVehicleID(playerid), -0.00101, 1.78877, 0.35295, 0.00000, 0.00000, 0.00000);
            AttachObjectToVehicle(nrg[playerid][4], GetPlayerVehicleID(playerid), 0.00000, 0.86230, 0.07600, 70.00000, 0.00000, -3.54000);
            AttachObjectToVehicle(nrg[playerid][5], GetPlayerVehicleID(playerid), 0.29508, -0.59719, 0.17033, 0.00000, 0.00000, -113.81998);
            AttachObjectToVehicle(nrg[playerid][6], GetPlayerVehicleID(playerid), -0.25780, -0.63270, 0.17030, 0.00000, 0.00000, 0.00000);
            ChangeVehicleColor(GetPlayerVehicleID(playerid), 0, 0);
            return 1;
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    nrg[playerid][0] = 0;
    nrg[playerid][1] = 0;
    nrg[playerid][2] = 0;
}

public OnPlayerDisconnect(playerid, reason)
{
   if(nrg[playerid][0]){
        DestroyObject(nrg[playerid][0]);
        DestroyObject(nrg[playerid][1]);
        DestroyObject(nrg[playerid][2]);
        DestroyObject(nrg[playerid][3]);
        RemovePlayerAttachedObject(playerid, 3);
        nrg[playerid][0] = 0;
    }
}
Thank you very much , It has been in operation
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)