What's the problem? else -
Glossy42O - 18.12.2014
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;
}
AW: What's the problem? else -
Flori - 18.12.2014
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.
Re: What's the problem? else -
JeaSon - 18.12.2014
just quick example! now you have to set that when you start earthquake set there "
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;
}
Re: What's the problem? else -
Glossy42O - 18.12.2014
Quote:
Originally Posted by Namer
just quick example! now you have to set that when you start earthquake set there "
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
Re: What's the problem? else -
Ada32 - 18.12.2014
well you are passing playerid in destroyobject, something i'm sure you didn't intend
Re: What's the problem? else -
Glossy42O - 18.12.2014
You mean to add playerid?
Re: What's the problem? else -
Ada32 - 18.12.2014
DestroyObject(playerid); //<--your code
https://sampwiki.blast.hk/wiki/DestroyObject <-- ref
Re: What's the problem? else -
BroZeus - 18.12.2014
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;
}
Re: What's the problem? else -
Kyance - 18.12.2014
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.
Re: What's the problem? else -
BroZeus - 18.12.2014
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.