Spawnar com armas aleatorias -
Ever_SH - 21.02.2015
Estou tentando fazer para quando a pessoa Spawnar ela nascer com varias armas aleatorias, achei uma forma de fazer na internet e adaptei do jeito que eu queria, mas fica aparecendo Warnings:
pawn Код:
new slot0 = random(0,1);
new slot1 = random(2,3,4,5,6,7,8,9);
new slot2 = random(22,23,24);
new slot3 = random(25,26);
new slot4 = random(28,29,32);
new slot5 = random(30,31);
new slot6 = random(33,34);
GivePlayerWeapon(playerid, slot0, 1);
GivePlayerWeapon(playerid, slot1, 1);
GivePlayerWeapon(playerid, slot2, 150);
GivePlayerWeapon(playerid, slot3, 90);
GivePlayerWeapon(playerid, slot4, 550);
GivePlayerWeapon(playerid, slot5, 400);
GivePlayerWeapon(playerid, slot6, 90);
GivePlayerWeapon(playerid, 16, 7);
Da linha slot0 até a slot6 aparece:
warning 202: number of arguments does not match definition
Re: Spawnar com armas aleatorias -
ZeZin - 21.02.2015
Olha os Argumentos.....
Re: Spawnar com armas aleatorias -
Ever_SH - 21.02.2015
Quote:
Originally Posted by ZeZin
Olha os Argumentos.....
|
Não entendi, fiz como nesse post:
http://forum.sa-mp.com/showpost.php?...1&postcount=24
Re: Spawnar com armas aleatorias -
JonathanFeitosa - 21.02.2015
Faзa uma matriz multidimensional quase idкntico ao da Wiki-samp.
https://sampwiki.blast.hk/wiki/Random
Re: Spawnar com armas aleatorias -
#Luca[S]. - 21.02.2015
PHP код:
// Topo
new iSpawnGive2[MAX_PLAYERS];
new gRandomWeaponsSpawns2[][] =
{
{25},//ID DA ARMA
{2},//ID DA ARMA
{15}//ID DA ARMA
};
// Qualquer Lugar embaixo do OnGameModeInit.
forward GivePlayerRandomWeapon2(playerid);
public GivePlayerRandomWeapon2(playerid)
{
if (iSpawnGive2[playerid] == 0)
{
new rand = random(sizeof(gRandomWeaponsSpawns2));
GivePlayerWeapon(playerid,gRandomWeaponsSpawns2[rand][0], 99999); // Armas.
}
return 1;
}
// OnPlayerSpawn //
GivePlayerRandomWeapon2(playerid);
By: @Riichard
Re: Spawnar com armas aleatorias -
Ever_SH - 21.02.2015
TenhoUmaDuvida também achei esse post do Riichard e usei esse código, como eu queria uma arma aleatória para cada Slot, eu fiz esse processo para cada slot, funcionou, mas ficou enorme o código:
pawn Код:
new ArmasSlot0[MAX_PLAYERS];
new ArmasSlot1[MAX_PLAYERS];
new ArmasSlot2[MAX_PLAYERS];
new ArmasSlot3[MAX_PLAYERS];
new ArmasSlot4[MAX_PLAYERS];
new ArmasSlot5[MAX_PLAYERS];
new ArmasSlot6[MAX_PLAYERS];
forward GivePlayerRandomSlot0(playerid);
forward GivePlayerRandomSlot1(playerid);
forward GivePlayerRandomSlot2(playerid);
forward GivePlayerRandomSlot3(playerid);
forward GivePlayerRandomSlot4(playerid);
forward GivePlayerRandomSlot5(playerid);
forward GivePlayerRandomSlot6(playerid);
OnPlayerSpawn
pawn Код:
GivePlayerRandomSlot0(playerid);
GivePlayerRandomSlot1(playerid);
GivePlayerRandomSlot2(playerid);
GivePlayerRandomSlot3(playerid);
GivePlayerRandomSlot4(playerid);
GivePlayerRandomSlot5(playerid);
GivePlayerRandomSlot6(playerid);
pawn Код:
public GivePlayerRandomSlot0(playerid)
{
if (ArmasSlot0[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot0));
GivePlayerWeapon(playerid,gRandomSlot0[rand][0],1); // Armas.
}
return 1;
}
public GivePlayerRandomSlot1(playerid)
{
if (ArmasSlot1[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot1));
GivePlayerWeapon(playerid,gRandomSlot1[rand][0],1); // Armas.
}
return 1;
}
public GivePlayerRandomSlot2(playerid)
{
if (ArmasSlot2[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot2));
GivePlayerWeapon(playerid,gRandomSlot2[rand][0],350); // Armas.
}
return 1;
}
public GivePlayerRandomSlot3(playerid)
{
if (ArmasSlot3[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot3));
GivePlayerWeapon(playerid,gRandomSlot3[rand][0],350); // Armas.
}
return 1;
}
public GivePlayerRandomSlot4(playerid)
{
if (ArmasSlot4[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot4));
GivePlayerWeapon(playerid,gRandomSlot4[rand][0],350); // Armas.
}
return 1;
}
public GivePlayerRandomSlot5(playerid)
{
if (ArmasSlot5[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot5));
GivePlayerWeapon(playerid,gRandomSlot5[rand][0],350); // Armas.
}
return 1;
}
public GivePlayerRandomSlot6(playerid)
{
if (ArmasSlot6[playerid] == 0)
{
new rand = random(sizeof(gRandomSlot6));
GivePlayerWeapon(playerid,gRandomSlot6[rand][0],350); // Armas.
}
return 1;
}
Tem como diminuir esse código, mas deixar funcionando igualmente?
Re: Spawnar com armas aleatorias -
ipsLuan - 21.02.2015
Poderia ter feito desse jeito com matrizes.
PHP код:
new ArmasSlot[7][MAX_PLAYERS];
forward GivePlayerRandomSlot(playerid);
public GivePlayerRandomSlote(playerid) {
if (ArmasSlot[0][playerid] == 0) {
new rand = random(sizeof(gRandomSlot0));
GivePlayerWeapon(playerid,gRandomSlot0[rand][0],1); // Armas.
}
else if(ArmasSlot[1][playerid] == 0) {
new rand = random(sizeof(gRandomSlot1));
GivePlayerWeapon(playerid,gRandomSlot1[rand][0],1); // Armas.
}
return 1;
}
E por aн vocк vai continuando...
Re: Spawnar com armas aleatorias -
#Luca[S]. - 21.02.2015
Tente:
PHP код:
new ArmasSlot0[MAX_PLAYERS];
new ArmasT[7][21]=
{
{0, 1},
{2, 3, 4, 5, 6, 7, 8,9},
{22, 23, 24},
{25, 26},
{28, 29, 32},
{30, 31},
{33, 34}
};
forward GivePlayerRandomSlot0(playerid);
public GivePlayerRandomSlot0(playerid)
{
if (ArmasSlot0[playerid] == 0)
{
new rand = random(sizeof(ArmasT));
GivePlayerWeapon(playerid,ArmasT[rand][0], 9999); // Armas.
}
return 1;
}
//OnPlayerSpawn
GivePlayerRandomSlot0(playerid);
Re: Spawnar com armas aleatorias -
DannielCooper - 21.02.2015
Usa switch.
Exemplo:
pawn Код:
new danniel;
switch(danniel){
case 0:GivePlayerWeapon...
case 1:GivePlayerWeapon...
}
Acho que й mais eficaz e bem mais simples que os modelos citados acima.
Para ler sobre switch:
https://sampwiki.blast.hk/wiki/Control_Structures#switch_2