11.05.2018, 05:31
Hi guys, i need code for spawn delay 10 sec of players , Someone can help me??
#include <a_samp>
new spawndelay[MAX_PLAYERS];
forward OneSecondUpdate();
public OnPlayerConnect(playerid){
spawndelay[playerid] = 0;
return 1;
}
public OnPlayerSpawn(playerid){
if(spawndelay[playerid] > 0){
SendClientMessage(playerid, 0xFF0000FF, "You spawned too fast!");
Kick(playerid);
}
spawndelay[playerid] = 10;
return 1;
}
public OnGameModeInit(){
SetTimer("OneSecondUpdate", 1000, 1);
return 1;
}
public OneSecondUpdate(){
for(new i; i < MAX_PLAYERS; i++){
spawndelay[i] -= 1;
}
}
i this is what you're looking for. if not, give me more details
PHP код:
|
CMD:class(playerid,params[]) { CLS[playerid]= SetTimerEx("ClassSelection", 10000, false, "i", playerid); SendClientMessage(playerid, 0xFF0000FF,"Change class in 10 sec"); ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nSurenos\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" , "Select", "");
make that code on your dialog response like Vennox gave you
dialogid == 1 |
CMD:class(playerid,params[])
{
CLS[playerid]= SetTimerEx("ClassSelection", 10000, false, "i", playerid);
SendClientMessage(playerid, 0xFF0000FF,"Change class in 10 sec");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nSurenos\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" , "Select", "");
forward ClassSelection(playerid);
public ClassSelection(playerid){
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nSurenos\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" , "Select", "");
}
CMD:class(playerid,params[])
{
CLS[playerid]= SetTimerEx("ClassSelection", 10000, false, "i", playerid);
SendClientMessage(playerid, 0xFF0000FF,"Your class will be changed in 10 seconds, please wait.");
return 1;
}
PHP код:
|
forward ClassSelection(playerid, class);
public ClassSelection(playerid, class){
//here you change the player's class: 0 = Negros, 1 = Civiles, 2 = Mafia, etc.
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
if(dialogid == 1){
SendClientMessage(playerid, -1, "Your class will be changed in 10 seconds.");
SetTimerEx("ClassSelection", 10000, false, "ii", playerid, listitem);
}
}
CMD:class(playerid,params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nSurenos\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" , "Select", "");
return 1;
}
PHP код:
|
new SKIN_MODELS[] = {
21,
2,
124,
122,
285,
108,
248,
295,
159,
50,
296,
287
};
new SKIN_NAMES[][] = {
"__Negros",
"_Civiles",
"___Mafia",
"____Nang",
"____Swat",
"_Surenos",
"___Biker",
"____Rich",
"_Farmers",
"Mechanic",
"____Pimp",
"Soldados"
};
public OnPlayerRequestClass(playerid, classid)
{
PlayAudioStreamForPlayer(playerid, "http://www.debbiewiseman.co.uk/samples/warriors.mp3");
SetSpawnInfo(playerid, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, true);
SetTimerEx("login_dialog", 0, 0, "i", playerid);
const MAX_SKINS = 312;
static string[MAX_SKINS * 16];
if (string[0] == EOS) {
for (new i; i < MAX_SKINS; i++) {
format(string, sizeof string, "%s%i\tID: %i\n", string, i, i);
}
}
return ShowPreviewModelDialog(playerid, 0, "Selecciуn de Equipo", SKIN_MODELS,SKIN_NAMES , "Select", "Cancel");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 0)
{
switch(listitem)
{
case 0: {
switch(random(6)) // Negros
{
case 0:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
case 1:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
case 2:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
case 3:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
case 4:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
case 5:
{
GameTextForPlayer(playerid, "~g~Skin Changed!", 3000, 3);
SetPlayerSkin(playerid, 21);
SetSpawnInfo(playerid,0,21,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);
SetPlayerColor(playerid, color_NEGROS);
}
}
}
}
return 1;
}
CMD:class(playerid,params[])
{
GetPlayerHealth(playerid, health);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nSurenos\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" , "Select", "");
SendClientMessage(playerid, -1, "Your class will be changed in 10 seconds.");
SetTimerEx("ClassSelection", 10000, false, "i", playerid);
}
public ClassSelection(playerid, dialogid, response, listitem, inputtext[])
{
switch(listitem)
{
case 0: {
switch(random(6)) // Negros
{
case 0:
{
SetPlayerSkin(playerid, 19);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
case 1:
{
SetPlayerSkin(playerid, 19);
SetPlayerPos(playerid, -2659.7424,260.6835,4.6328);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
case 2:
{
SetPlayerSkin(playerid, 19);
SetPlayerPos(playerid, -2695.9822,262.4749,4.6328);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
case 3:
{
SetPlayerSkin(playerid, 19);
SetPlayerPos(playerid, -2694.5286,276.3913,4.3359);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
case 4:
{
SetPlayerSkin(playerid, 19);
SetPlayerPos(playerid,-2659.1301,275.6968,4.3359);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
case 5:
{
SetPlayerSkin(playerid, 19);
SetPlayerPos(playerid, -2665.8315,237.6608,4.3359);
GivePlayerWeapon(playerid, 30, 150);
GivePlayerWeapon(playerid, 25, 50);
GivePlayerWeapon(playerid, 29, 150);
SetPlayerColor(playerid, color_NEGROS);
}
}
}
Very thx, solve it!!, I have a problem now ... I have 2 dialogues, and every time I use / class the dialog 0 is used, why does this happen??
PHP код:
|
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
//TogglePlayerSpectating(playerid, true);
TogglePlayerSpectating(playerid, false);
return 1;
}