What's the problem? else
#1

I don't see anything wrong here.

Код:
CMD:stearth(playerid, params[])
{
 if(IsPlayerAdmin(playerid))
 {
   SendClientMessage(playerid, -1, "{00CC00}[SUCCESS]: You have stopped the earthquake.");
   DestroyObject(playerid);
   SetPlayerDrunkLevel(playerid, 0);
   StopAudioStreamForPlayer(playerid);
 }
 else
 {
   SendClientMessage(playerid, -1, "{FF0000}ERROR: No earthquake going on now.");
 }
 else //<<<  error 029: invalid expression, assumed zero
 {
   SendClientMessage(playerid, -1, "{FF0000}Only rcon admins can use this command!");
 }
 return 1;
}
Reply
#2

What do you want to do? You use 2 else following each other,it can't work.

You need to use a if(makeanarrayforearthquakecheck) after IsPlayerAdmin to check if the earthquake is running or not.
Reply
#3

just quick example! now you have to set that when you start earthquake set there "
pawn Код:
EarthQuake = 1;
pawn Код:
new EarthQuake; // define this at top where you have other variables
CMD:stearth(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(EarthQuake == 1)
        {
            SendClientMessage(playerid, -1, "{00CC00}[SUCCESS]: You have stopped the earthquake.");
            DestroyObject(playerid);
            EarthQuake = 0;
            SetPlayerDrunkLevel(playerid, 0);
            StopAudioStreamForPlayer(playerid);
        } else return SendClientMessage(playerid, -1, "{FF0000}ERROR: No earthquake going on now.");
    } else return SendClientMessage(playerid, -1, "{FF0000}Only rcon admins can use this command!");
    return 1;
}
Reply
#4

Quote:
Originally Posted by Namer
Посмотреть сообщение
just quick example! now you have to set that when you start earthquake set there "
pawn Код:
EarthQuake = 1;
pawn Код:
new EarthQuake; // define this at top where you have other variables
CMD:stearth(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(EarthQuake == 1)
        {
            SendClientMessage(playerid, -1, "{00CC00}[SUCCESS]: You have stopped the earthquake.");
            DestroyObject(playerid);
            EarthQuake = 0;
            SetPlayerDrunkLevel(playerid, 0);
            StopAudioStreamForPlayer(playerid);
        } else return SendClientMessage(playerid, -1, "{FF0000}ERROR: No earthquake going on now.");
    } else return SendClientMessage(playerid, -1, "{FF0000}Only rcon admins can use this command!");
    return 1;
}
works perfectly

1 prob

after i stop the earthquake if i use /earthquake again i crash and the object won't dissapear
Reply
#5

well you are passing playerid in destroyobject, something i'm sure you didn't intend
Reply
#6

You mean to add playerid?
Reply
#7

DestroyObject(playerid); //<--your code

https://sampwiki.blast.hk/wiki/DestroyObject <-- ref
Reply
#8

As far as i see the script has many bugs..
It would be like this -
pawn Код:
new earth[MAX_PLAYERS];//on top

earth[playerid] = 1;//put this where u begin the earthquick

CMD:stearth(playerid, params[])
{
 if(!IsPlayerAdmin(playerid))retrun SendClientMessage(playerid, -1, "{FF0000}Only rcon admins can use this command!");
 if(earth[player] == 0)retrun SendClientMessage(playerid, -1, "{FF0000}ERROR: No earthquake going on now.");
 
   SendClientMessage(playerid, -1, "{00CC00}[SUCCESS]: You have stopped the earthquake.");
   // DestroyObject(playerid); You need to put object id returned by createobject() here
   SetPlayerDrunkLevel(playerid, 0);
   StopAudioStreamForPlayer(playerid);
   earth[playerid] = 0;
   return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    earth[playerid] = 0;
    return 1;
}
Reply
#9

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
As far as i see the script has many bugs..
It would be like this -
pawn Код:
new earth[MAX_PLAYERS];//on top

earth[playerid] = 1;//put this where u begin the earthquick

CMD:stearth(playerid, params[])
{
 if(!IsPlayerAdmin(playerid))retrun SendClientMessage(playerid, -1, "{FF0000}Only rcon admins can use this command!");
 if(earth[player] == 0)retrun SendClientMessage(playerid, -1, "{FF0000}ERROR: No earthquake going on now.");
 
   SendClientMessage(playerid, -1, "{00CC00}[SUCCESS]: You have stopped the earthquake.");
   // DestroyObject(playerid); You need to put object id returned by createobject() here
   SetPlayerDrunkLevel(playerid, 0);
   StopAudioStreamForPlayer(playerid);
   earth[playerid] = 0;
   return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    earth[playerid] = 0;
    return 1;
}
[MAX_PLAYERS] isn't needed d:

OT:
You can create the earthquake objects by using;
pawn Код:
new EarthquakeObject[10]; //0, 1, 2, 3, 4, 5, 6, 7, 8, 9    INCREASE IF NEEDED
To create the objects, example.

pawn Код:
//Under the start-earthquake callback or w.e
EarthquakeObject[0] = CreateObject(...);
EarthquakeObject[1] = CreateObject(...);
....
EarthquakeObject[9] = CreateObject(...);

//I guess you'd have to destroy the original objects though.
Reply
#10

Quote:
Originally Posted by Kyance
Посмотреть сообщение
[MAX_PLAYERS] isn't needed d:

OT:
You can create the earthquake objects by using;
pawn Код:
new EarthquakeObject[10]; //0, 1, 2, 3, 4, 5, 6, 7, 8, 9    INCREASE IF NEEDED
To create the objects, example.

pawn Код:
//Under the start-earthquake callback or w.e
EarthquakeObject[0] = CreateObject(...);
EarthquakeObject[1] = CreateObject(...);
....
EarthquakeObject[9] = CreateObject(...);

//I guess you'd have to destroy the original objects though.
Oh ye didn't notice, thought that he is creating the system in which every player can have his/her own earthquake.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)