PDA

View Full Version : Crashs with class system


Mijata
31/03/2015, 08:20 PM
why players have crashs with class system when is player killed sometimes he is crashed because problem is class system?? help what is problem

#define DIALOG_CLASS 0


public OnPlayerSpawn(playerid)
{

ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_STYL E_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");

return 1;

}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CLASS)
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_STYL E_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
if(response)
{
switch(listitem)
{
case 0:
{
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,16,1);
GivePlayerWeapon(playerid,27,100);
GivePlayerWeapon(playerid,31,80);
}
case 1:
{
if(GetPlayerScore(playerid) < 100) return SendClientMessage(playerid,0xFF0000,"You must have at least 100 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,34,50);
GivePlayerWeapon(playerid,4,1);
GivePlayerWeapon(playerid,23,100);
GivePlayerWeapon(playerid,46,1);

}
case 2:
{
if(GetPlayerScore(playerid) < 300) return SendClientMessage(playerid,0xFF0000,"You must have at least 300 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,25,60);
GivePlayerWeapon(playerid,32,150);
GivePlayerWeapon(playerid,16,1);


}
case 3:
{
if(GetPlayerScore(playerid) < 500) return SendClientMessage(playerid,0xFF0000,"You must have at least 300 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,37,300);
GivePlayerWeapon(playerid,18,5);
GivePlayerWeapon(playerid,24,20);
GivePlayerWeapon(playerid,4,1);
GivePlayerWeapon(playerid,25,100);
}
case 4:
{
if(GetPlayerScore(playerid) < 1000) return SendClientMessage(playerid,0xFF0000,"You must have at least 1000 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,26,150);
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,16,2);
GivePlayerWeapon(playerid,31,150);

}
}
}
}
return 0;
}

Gammix
01/04/2015, 07:00 AM
I think you have missed a listitem in your dialog. And you cant have a blank listitem in your dialog. Dont use "\n" in the begining.
ShowPlayerDialog(playerid, _, _, _, "item1\n...", _, _);
"_" means your default values for the param. You have 5 cases in callback but 4 items in dialog.

Also, in dialog response callback, try to use indentation rather using "," for 1 statement after another.
And dont return 0 in it.

I dont see anything else causing problem from the provided code.

Mya
01/04/2015, 07:46 AM
maybe this is help your problem :D

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CLASS)
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_STYL E_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
if(response)
{
switch(listitem)
{
case 0:
{
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,16,1);
GivePlayerWeapon(playerid,27,100);
GivePlayerWeapon(playerid,31,80);
}
case 1:
{
if(GetPlayerScore(playerid) < 100) return SendClientMessage(playerid,0xFF0000,"You must have at least 100 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,34,50);
GivePlayerWeapon(playerid,4,1);
GivePlayerWeapon(playerid,23,100);
GivePlayerWeapon(playerid,46,1);

}
case 2:
{
if(GetPlayerScore(playerid) < 300) return SendClientMessage(playerid,0xFF0000,"You must have at least 300 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,25,60);
GivePlayerWeapon(playerid,32,150);
GivePlayerWeapon(playerid,16,1);


}
case 3:
{
if(GetPlayerScore(playerid) < 500) return SendClientMessage(playerid,0xFF0000,"You must have at least 300 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,37,300);
GivePlayerWeapon(playerid,18,5);
GivePlayerWeapon(playerid,24,20);
GivePlayerWeapon(playerid,4,1);
GivePlayerWeapon(playerid,25,100);
}
case 4:
{
if(GetPlayerScore(playerid) < 1000) return SendClientMessage(playerid,0xFF0000,"You must have at least 1000 score to play in this class!"),ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_ST YLE_LIST,"Class selection:","\n(100 score required)\n\n(500 score required)\n(1000 score required)","Choose","");
GivePlayerWeapon(playerid,26,150);
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,16,2);
GivePlayerWeapon(playerid,31,150);

}
}
}
}
return 1;
}

Mijata
09/04/2015, 12:27 PM
no again same problem

Chlorine
09/04/2015, 12:33 PM
Try this:

public OnPlayerSpawn(playerid)
{

ShowPlayerDialog(playerid,DIALOG_CLASS,DIALOG_STYL E_LIST,"Class selection:","(100 score required)\n(300 score required)\n(500 score required)\n(1000 score required)","Choose","");

return 1;

}

[ABK]Antonio
09/04/2015, 12:33 PM
He said sometimes, which leads me to believe this has nothing to do with the dialog system. Not sure what your actual problem is, but I doubt it's that.