Need a little help (dialog) -
mickos - 30.08.2012
Done
Re: Need a little help (dialog) -
Ranama - 30.08.2012
Код:
if(diloagid == dialogid +2){//why are you doing it as this? "dialogid+2"???? and use switch, they are much faster then if
if(response){
switch(listitem){
case 0:{
//ls spawn
}
case 1:{
//sfls spawn
}
case 2:{
//lv spawn
}
}
'
Hope you understand
Re: Need a little help (dialog) -
mickos - 30.08.2012
Deleted
Re: Need a little help (dialog) -
leonardo1434 - 30.08.2012
Quote:
Originally Posted by Ranama
Код:
use switch, they are much faster then if
'
|
You're wrong, just made a quick test to prove to you.
pawn Код:
public OnFilterScriptInit()
{
static a = 0,b = 10000,tt[2];
tt[0] = GetTickCount();
for(; a < b; ++a)
{
switch(a)
{
case 0..10000:
{
b = 100000000;
for(; 0 < b; --b)
{
}
}
}
}
tt[0] = GetTickCount() - tt[0];
a = 0,b = 10000;
tt[1] = GetTickCount();
for(; a < b; ++a)
{
if(a < 10000)
{
b = 100000000;
for(; 0 < b; --b)
{
}
}
}
tt[1] = GetTickCount() - tt[1];
printf(#%d - %d , tt[0],tt[1]);
}
There's no a big difference. but is NOT more fast.
Back on topic:
it should be something like this
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOGID:
{
if(response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid, DIALOGID+1, DIALOG_STYLE_LIST, "Which player would you like to play as?", "Police\nDrug Dealer", "Select", "Cancel");
}
}
}
}
case DIALOGID+1:
{
if(response)
{
switch(listitem)
{
case 0:
{
SetPlayerSkin(playerid, 61); //Police
SetPlayerColor(playerid, 0x6086D6FF);
new rand = random(sizeof(lsaRandomSpawns));
SetPlayerPos(playerid, lsaRandomSpawns[rand][0], lsaRandomSpawns[rand][1], lsaRandomSpawns[rand][2]);
SetPlayerFacingAngle(playerid,lsaRandomSpawns[rand][3]);
SetCameraBehindPlayer(playerid);
return ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Where would you like to spawn?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "Cancel");
}
case 1:
{
SetPlayerSkin(playerid, 7); //Drug Dealer
SetPlayerColor(playerid, 0xD66060FF);
new rand = random(sizeof(sfaRandomSpawns));
SetPlayerPos(playerid, sfaRandomSpawns[rand][0], sfaRandomSpawns[rand][1], sfaRandomSpawns[rand][2]);
SetPlayerFacingAngle(playerid,sfaRandomSpawns[rand][3]);
SetCameraBehindPlayer(playerid);
return ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Where would you like to spawn?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "Cancel");
}
}
}
}
}
return 1;
}
Re: Need a little help (dialog) -
mickos - 30.08.2012
Deleted
Re: Need a little help (dialog) -
leonardo1434 - 30.08.2012
Just do that.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOGID:
{
if(response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid, DIALOGID+1, DIALOG_STYLE_LIST, "Which player would you like to play as?", "Police\nDrug Dealer", "Select", "Cancel");
}
}
}
}
case DIALOGID+1:
{
if(response)
{
switch(listitem)
{
case 0:
{
SetPlayerSkin(playerid, 61); //Police
SetPlayerColor(playerid, 0x6086D6FF);
return ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Where would you like to spawn?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "Cancel");
}
case 1:
{
SetPlayerSkin(playerid, 7); //Drug Dealer
SetPlayerColor(playerid, 0xD66060FF);
return ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_LIST, "Where would you like to spawn?", "Los Santos\nSan Fierro\nLas Venturas", "Select", "Cancel");
}
}
}
}
case DIALOGID+2:
{
if(response)
{
switch(listitem)
{
case 0:
{
// here you put all stuff about LS.
}
case 1:
{
// here you put all stuff about SF.
}
case 2:
{
// here you put all stuff about LV.
}
}
}
}
}
return 1;
}
Re: Need a little help (dialog) -
mickos - 30.08.2012
Deleted
Re: Need a little help (dialog) -
leonardo1434 - 30.08.2012
just make another dialog as i did, and start by adding each spawn. just study the code that i've post and you will get his logic.
Re: Need a little help (dialog) -
mickos - 30.08.2012
Ahh oke, the first one is for the police? and if i make a 2nd it will be for the drug dealer?
Re: Need a little help (dialog) -
leonardo1434 - 30.08.2012
Take a look in the "dialogid + 1", case "0" is the policer, and case "1" is the drug seller.
The "dialogid + 2" is for their spawn's places.