PDA

View Full Version : OnDialogResponse


fuckingcruse
26/03/2015, 08:03 AM
Hello , I have a a Dialog for weapons , I.e DIALOG_WEAPONS and I made one more for SPawn , DIALOG_TELES

I made the dialog like this and it's working ..


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEAPONS)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid)<500) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_DEAGLE, 150);
GivePlayerMoney(playerid,-500);
}
case 1:
{
if(GetPlayerMoney(playerid)<500) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_CHAINSAW , 1);
GivePlayerMoney(playerid, -500);
}
case 2:
{
if(GetPlayerMoney(playerid)<500) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_SILENCED , 150);
GivePlayerMoney(playerid, -500);
}
case 3:
{
if(GetPlayerMoney(playerid)<700) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_SHOTGUN , 150);
GivePlayerMoney(playerid, -700);
}
case 4:
{
if(GetPlayerMoney(playerid)<1000) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_SAWEDOFF , 200);
GivePlayerMoney(playerid, -1000);
}
case 5:
{
if(GetPlayerMoney(playerid)<1000) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_SHOTGSPA , 200);
GivePlayerMoney(playerid, -1000);
}
case 6:
{
if(GetPlayerMoney(playerid)<800) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_MP5 , 1000);
GivePlayerMoney(playerid, -800);
}
case 7:
{
if(GetPlayerMoney(playerid)<800) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_UZI , 1000);
GivePlayerMoney(playerid, -800);
}
case 8:
{
if(GetPlayerMoney(playerid)<1500) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_M4 , 1000);
GivePlayerMoney(playerid, -1500);
}
case 9:
{
if(GetPlayerMoney(playerid)<1500) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_AK47 , 1000);
GivePlayerMoney(playerid, -1500);
}
case 10:
{
if(GetPlayerMoney(playerid)<2000) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_RIFLE , 1000);
GivePlayerMoney(playerid, -2000);
}
case 11:
{
if(GetPlayerMoney(playerid)<2000) return SendClientMessage(playerid,COLOR_BLUE, " Not Enough Money to buy Gun , you choosed");
GivePlayerWeapon(playerid, WEAPON_SNIPER , 1000);
GivePlayerMoney(playerid, -2000);
}




}
}

return 1;



}

return 0;
}



And i want to add this in this


if(dialogid == DIALOG_TELES)
{
if(response)
{
switch(listitem)
{
case 0:
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLS[Random][3]);
}
case 1:
{
new Random = random(sizeof(RandomSpawnLV));
SetPlayerPos(playerid, RandomSpawnLV[Random][0], RandomSpawnLV[Random][1], RandomSpawnLV[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLV[Random][3]);
}
case 2:
{
new Random = random(sizeof(RandomSpawnSF));
SetPlayerPos(playerid, RandomSpawnSF[Random][0], RandomSpawnSF[Random][1], RandomSpawnSF[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnSF[Random][3]);
}
}

}

}

But i can't Add these both.. Anyone can help?

CalvinC
26/03/2015, 08:33 AM
Yes you can, just add it after the other dialog codes.
if(dialogid == DIALOG_WEAPONS)
{
// Code
}
else if(dialoid == DIALOG_TELES)
{
// Code
}
Although using a switch would be faster.
switch(dialogid)
{
case DIALOG_WEAPONS:
{
// Code
}
case DIALOG_TELES:
{
// Code
}
}

fuckingcruse
26/03/2015, 08:44 AM
And Dude another error , i post it here , why to make another topic,
See this codes



#include <a_samp>
#include <zcmd>
#define DIALOG_TELES 3

new Float:RandomSpawnLS[][] =
{
{1091.0786,-1794.4513,13.6197,17.5902},
{1959.8345,-2181.7620,13.5469,1.2967},
{1186.0222,-1324.5660,13.5593,267.7775},
{1316.6267,-910.7559,38.0429,178.3317},
{1126.6519,-2036.7144,69.8838,271.3926},
{2426.2029,-2457.7190,13.6201,316.5363}
};
new Float:RandomSpawnLV[][] =
{
{1723.7269,1601.9326,10.0166,253.8372},
{2025.2045,1545.3309,10.8203,273.8063},
{2304.7341,2426.7422,10.8203,182.1671},
{2519.7900,1824.4259,10.8129,92.7213},
{2233.5547,1285.6110,10.8203,91.7813},
{1061.9387,1807.1115,10.8203,1.3443}
};
new Float:RandomSpawnSF[][] =
{
{-1983.3813,137.4470,27.6875,88.2716},
{-2027.1277,-93.8835,35.1641,3.7260},
{-2724.3335,-314.1563,7.1869,49.9080},
{-2755.9751,375.4995,4.3350,273.4851},
{-2489.6787,1200.6038,37.1529,215.2514},
{-1508.9319,922.6257,7.1875,91.1702},
{-1555.0504,-439.7008,6.0000,137.3754}

};

enum pInfo
{
pLS,
pLV,
pSF

}
new pData[MAX_PLAYERS][pInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif



public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}



public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

CMD:Tele(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_TELES,DIALOG_STYL E_LIST,"TELES","LS\nLV\nSF","Select","Close");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TELES)
{
if(response)
{
switch(listitem)
{
case 0:
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLS[Random][3]);
pData[playerid][pLS] = 1;
}
case 1:
{
new Random = random(sizeof(RandomSpawnLV));
SetPlayerPos(playerid, RandomSpawnLV[Random][0], RandomSpawnLV[Random][1], RandomSpawnLV[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLV[Random][3]);
pData[playerid][pLV] = 1;
}
case 2:
{
new Random = random(sizeof(RandomSpawnSF));
SetPlayerPos(playerid, RandomSpawnSF[Random][0], RandomSpawnSF[Random][1], RandomSpawnSF[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnSF[Random][3]);
pData[playerid][pSF] = 1;
}
}

}

}
return 1;
}


public OnPlayerSpawn(playerid)
{
if(pData[playerid][pLS])
return
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);

return 1;
}


It shows error , I just want to save that variable to the pInfo and it's done , can you say what's wrong ? you can understand i am doing by the codes , how to clear the error?

Ahmad45123
26/03/2015, 08:55 AM
And Dude another error , i post it here , why to make another topic,
See this codes



#include <a_samp>
#include <zcmd>
#define DIALOG_TELES 3

new Float:RandomSpawnLS[][] =
{
{1091.0786,-1794.4513,13.6197,17.5902},
{1959.8345,-2181.7620,13.5469,1.2967},
{1186.0222,-1324.5660,13.5593,267.7775},
{1316.6267,-910.7559,38.0429,178.3317},
{1126.6519,-2036.7144,69.8838,271.3926},
{2426.2029,-2457.7190,13.6201,316.5363}
};
new Float:RandomSpawnLV[][] =
{
{1723.7269,1601.9326,10.0166,253.8372},
{2025.2045,1545.3309,10.8203,273.8063},
{2304.7341,2426.7422,10.8203,182.1671},
{2519.7900,1824.4259,10.8129,92.7213},
{2233.5547,1285.6110,10.8203,91.7813},
{1061.9387,1807.1115,10.8203,1.3443}
};
new Float:RandomSpawnSF[][] =
{
{-1983.3813,137.4470,27.6875,88.2716},
{-2027.1277,-93.8835,35.1641,3.7260},
{-2724.3335,-314.1563,7.1869,49.9080},
{-2755.9751,375.4995,4.3350,273.4851},
{-2489.6787,1200.6038,37.1529,215.2514},
{-1508.9319,922.6257,7.1875,91.1702},
{-1555.0504,-439.7008,6.0000,137.3754}

};

enum pInfo
{
pLS,
pLV,
pSF

}
new pData[MAX_PLAYERS][pInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif



public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}



public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

CMD:Tele(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_TELES,DIALOG_STYL E_LIST,"TELES","LS\nLV\nSF","Select","Close");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TELES)
{
if(response)
{
switch(listitem)
{
case 0:
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLS[Random][3]);
pData[playerid][pLS] = 1;
}
case 1:
{
new Random = random(sizeof(RandomSpawnLV));
SetPlayerPos(playerid, RandomSpawnLV[Random][0], RandomSpawnLV[Random][1], RandomSpawnLV[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLV[Random][3]);
pData[playerid][pLV] = 1;
}
case 2:
{
new Random = random(sizeof(RandomSpawnSF));
SetPlayerPos(playerid, RandomSpawnSF[Random][0], RandomSpawnSF[Random][1], RandomSpawnSF[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnSF[Random][3]);
pData[playerid][pSF] = 1;
}
}

}

}
return 1;
}


public OnPlayerSpawn(playerid)
{
if(pData[playerid][pLS])
return
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);

return 1;
}


It shows error , I just want to save that variable to the pInfo and it's done , can you say what's wrong ? you can understand i am doing by the codes , how to clear the error?
Cant you just help and show us where is the error and what is it ?

fuckingcruse
26/03/2015, 09:06 AM
ok , so see this is the code..

Once i choose LS , it saves to LS when i /q and come it is working but.. When choose another City it still spawn at LS.. :( And i have done some changes..

If you can help me say me

CalvinC
26/03/2015, 09:24 AM
When setting his pLS, pSF or pLV to 1, you should reset the others.
Right now what you're doing is:
*Player selects LS*
pLS = 1

*Then afterwards the player selects SF*
pSF = 1

So both pLS and pSF would be set to 1, instead you should reset the others:
*Player selects LS*
pLS = 1
pSF = 0
pLV = 0

*Then afterwards the player selects SF*
pSF = 1
pLS = 0
pLV = 0

And your OnPlayerSpawn can only detect if his pLS is set to 1, not the others.
And it also seems wrong as well, i think you should do:
if(pData[playerid][pLS])
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
}

Ahmad45123
26/03/2015, 09:32 AM
Instead of doing a variable for each one...
Just do one variable called: pCity and you can have id's set to each city...
So you can do:

#include <a_samp>
#include <zcmd>
#define DIALOG_TELES 3

new Float:RandomSpawnLS[][] =
{
{1091.0786,-1794.4513,13.6197,17.5902},
{1959.8345,-2181.7620,13.5469,1.2967},
{1186.0222,-1324.5660,13.5593,267.7775},
{1316.6267,-910.7559,38.0429,178.3317},
{1126.6519,-2036.7144,69.8838,271.3926},
{2426.2029,-2457.7190,13.6201,316.5363}
};
new Float:RandomSpawnLV[][] =
{
{1723.7269,1601.9326,10.0166,253.8372},
{2025.2045,1545.3309,10.8203,273.8063},
{2304.7341,2426.7422,10.8203,182.1671},
{2519.7900,1824.4259,10.8129,92.7213},
{2233.5547,1285.6110,10.8203,91.7813},
{1061.9387,1807.1115,10.8203,1.3443}
};
new Float:RandomSpawnSF[][] =
{
{-1983.3813,137.4470,27.6875,88.2716},
{-2027.1277,-93.8835,35.1641,3.7260},
{-2724.3335,-314.1563,7.1869,49.9080},
{-2755.9751,375.4995,4.3350,273.4851},
{-2489.6787,1200.6038,37.1529,215.2514},
{-1508.9319,922.6257,7.1875,91.1702},
{-1555.0504,-439.7008,6.0000,137.3754}

};

enum pInfo
{
pCity //Will store ID of the current city here. (Ofcousre this will need to be saved)
}
/*
1: Will be LS
2: Will be LV
3: Will be SF
*/
new pData[MAX_PLAYERS][pInfo];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif



public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}



public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

CMD:Tele(playerid,params[])
{
ShowPlayerDialog(playerid,DIALOG_TELES,DIALOG_STYL E_LIST,"TELES","LS\nLV\nSF","Select","Close");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TELES)
{
if(response)
{
switch(listitem)
{
case 0:
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLS[Random][3]);
pData[playerid][pCity] = 1;
}
case 1:
{
new Random = random(sizeof(RandomSpawnLV));
SetPlayerPos(playerid, RandomSpawnLV[Random][0], RandomSpawnLV[Random][1], RandomSpawnLV[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLV[Random][3]);
pData[playerid][pCity] = 2;
}
case 2:
{
new Random = random(sizeof(RandomSpawnSF));
SetPlayerPos(playerid, RandomSpawnSF[Random][0], RandomSpawnSF[Random][1], RandomSpawnSF[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnSF[Random][3]);
pData[playerid][pCity] = 3;
}
}

}

}
return 1;
}


public OnPlayerSpawn(playerid)
{
switch(pData[playerid][pCity])
{
case 1:
{
new Random = random(sizeof(RandomSpawnLS));
SetPlayerPos(playerid, RandomSpawnLS[Random][0], RandomSpawnLS[Random][1], RandomSpawnLS[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLS[Random][3]);
}
case 2:
{
new Random = random(sizeof(RandomSpawnLV));
SetPlayerPos(playerid, RandomSpawnLV[Random][0], RandomSpawnLV[Random][1], RandomSpawnLV[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnLV[Random][3]);
}
case 3:
{
new Random = random(sizeof(RandomSpawnSF));
SetPlayerPos(playerid, RandomSpawnSF[Random][0], RandomSpawnSF[Random][1], RandomSpawnSF[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnSF[Random][3]);
}
}
return 1;
}

And as I said in the comments... You will have to save and load the pCity var just like how you did with pLS,pLV and pSF

fuckingcruse
26/03/2015, 09:34 AM
Let me try boths

fuckingcruse
26/03/2015, 09:43 AM
Working ;) thanks both :)