PDA

View Full Version : Class selection problem.


Kyance
21/10/2013, 08:57 AM
So, uh, im trying something new.
Basically, i've made a script that should make you choose a class, on your first spawn
But sadly it doesn't do that
I've tried some stuff, but eh.. no luck :\
Script..

public OnPlayerSpawn(playerid)
{
if Class_Chosen{ playerid } == 1 *then return SendClientMessage(playerid, COLOR_ORANGE, "Use /sc to change your class!");
else
ShowPlayerDialog(playerid, DIALOG_CLASS1, DIALOG_STYLE_LIST, "Classes", "Sniper\nMedic\nAssault\nEngineer", "Select", "Cancel");
return 1;
}

Class selection Dialog thing.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_CLASS1:
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerScore(playerid) < 150) return SendClientMessage(playerid, COLOR_RED, "You need to have 150 score to use the Sniper class!");
else SendClientMessage(playerid, COLOR_GREEN, "Sniper class chosen!");
GivePlayerWeapon(playerid, 4, 1);
GivePlayerWeapon(playerid, 23, 500);
GivePlayerWeapon(playerid, 25, 150);
GivePlayerWeapon(playerid, 29, 850);
GivePlayerWeapon(playerid, 34, 500);
SetPlayerArmour(playerid, 99.0);
Class_Chosen{ playerid } = 1;
}
case 1:
{
if(GetPlayerScore(playerid) < 150) return SendClientMessage(playerid, COLOR_RED, "You need to have 150 score to use the Medic class!");
else SendClientMessage(playerid, COLOR_GREEN, "Medic class chosen!");
SendClientMessage(playerid, COLOR_GREEN, "You can use /heal to heal your teammates!");
SetPlayerSkin(playerid, 275);
GivePlayerWeapon(playerid, 16, 1);
GivePlayerWeapon(playerid, 22, 257);
GivePlayerWeapon(playerid, 25, 350);
GivePlayerWeapon(playerid, 30, 550);
SetPlayerArmour(playerid, 99);
Class_Chosen{ playerid } = 1;
}
case 2:
{
SendClientMessage(playerid, COLOR_GREEN, "Assault class chosen!");
GivePlayerWeapon(playerid, 16, 3);
GivePlayerWeapon(playerid, 24, 320);
GivePlayerWeapon(playerid, 27, 180);
GivePlayerWeapon(playerid, 29, 500);
GivePlayerWeapon(playerid, 31, 500);
GivePlayerWeapon(playerid, 35, 4);
SetPlayerArmour(playerid, 99);
Class_Chosen{ playerid } = 1;
}
case 3:
{
if(GetPlayerScore(playerid) < 300) return SendClientMessage(playerid, COLOR_RED, "You need to have 300 score to use the Engineer class");
else SendClientMessage(playerid, COLOR_GREEN, "Engineer class chosen!");
SendClientMessage(playerid, COLOR_GREEN, "You can use /fix to repair your own vehicle, and /repair to repair your teammates vehicles");
SetPlayerSkin(playerid, 50);
GivePlayerWeapon(playerid, 16, 1);
GivePlayerWeapon(playerid, 24, 157);
GivePlayerWeapon(playerid, 27, 127);
GivePlayerWeapon(playerid, 31, 540);
GivePlayerWeapon(playerid, 35, 2);
Class_Chosen{ playerid } = 1;
}
}
}
return 1;
}
... other dialog response scripts here ...

Basically i thought that the "Class_Chosen{playerid} = 1;" should make the OnPlayerSpawn realize, that the player doesn't need to select a class anymore..
d:
Additional command:

CMD:sc(playerid, params[]) {
Class_Chosen{ playerid } = 0;
SendClientMessage(playerid, COLOR_ORANGE, "Switching class after the next death.");
return 1;
}

I've tried making it "set" etc etc, but then it gave me errors like
test.pwn(545) : error 017: undefined symbol "set"
etc.. :[

Kyance
21/10/2013, 11:39 AM
Never-mind, thanks to Konstantinos "tutorial" i fixed it!