Recompensas por Escribir una frase. -
ronaldfa - 28.05.2015
Lo que pasa es que estoy tratando de instalar un sistema de ejemplo:
"El primero en escribir KJAS9das8zxl ganara 29000$ y 5 Score"..
Y Sale el mensaje y todo pero al escribir la frase no me da ni el dinero ni el Score...
Aquн estбn las lineas, a ver si alguien me dice que esta mal..
Primero tenemos el new:
PHP код:
new
xCharacters[][] =
{
"A", "B", "C", "D", "E", "F", "G", "H", "*", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "_", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
},
xChars[16] = "",
xReactionTimer,
xCash,
xScore,
bool: xTestBusy
;
Despuйs el siguiente cуdigo:
PHP код:
if(!strcmp(xChars, text, false))
{
new string[128],NameNick[MAX_PLAYER_NAME];
GetPlayerName(playerid, NameNick, sizeof(NameNick));
format(string, sizeof(string), "« {ffffff}' \%s ' {00FFFF}es el ganador del test de reacciуn »", NameNick);
SendClientMessageToAll(0x00FFFFAA, string);
format(string, sizeof(string), "« Tu has ganado $%d + %d de score »", xCash, xScore);
SendClientMessage(playerid, 0x00FF00C8, string);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
GameTextForPlayer(playerid, "~y~winner~n~~p~Premio Obtenido", 3000, 3);
GivePlayerMoney(playerid, xCash);
SetPlayerScore(playerid, GetPlayerScore(playerid) + xScore);
SavePlayer(playerid);
#if defined USE_STATS
PlayerInfo[playerid][Kills] = PlayerInfo[playerid][Kills]+ xScore;
#endif
xReactionTimer = SetTimer("xReactionTest", TIME, 1);
xTestBusy = false;
}
}
}
return 1;
}
Despuйs la funciуn:
PHP код:
function xReactionTest()
{
new
xLength = (random(8) + 5),
string[128]
;
xCash = (random(10000) + 20000);
xScore = (random(2)+4);
format(xChars, sizeof(xChars), "");
Loop(x, xLength) format(xChars, sizeof(xChars), "%s%s", xChars, xCharacters[random(sizeof(xCharacters))][0]);
format(string, sizeof(string), "[Test]: {00FFFF}Quien sea el primero en escribir{FFFFFF} %s {00FFFF}ganara $%d +%d de score", xChars, xCash, xScore);
SendClientMessageToAll(0xFFFFFFAA, string);
KillTimer(xReactionTimer);
xTestBusy = true;
// SetTimer("xReactionProgress", 50000, 0);
return 1;
}
Esto estaba en GameModeInit, Supongo yo que es tambien del codigo porque arriba en la funcion esta.
PHP код:
xReactionTimer = SetTimer("xReactionTest", TIME, 1);
Espero que me puedan ayudar.
Re: Recompensas por Escribir una frase. -
SickAttack - 28.05.2015
Por favor toma el siguiente script como referencia:
pawn Код:
// [ DEVELOPMENT GAMEMODE ]
// INCLUDES:
#include <a_samp>
#include <zcmd>
// DEFINES:
// GENERAL:
#define MAX_CHARACTERS 62
#define INTERVAL_TIME 120000
#define MAX_LENGTH 10
#define MAX_AWARDS 2
// FUNCTIONS:
#define function%0(%1) forward%0(%1); public%0(%1)
#define plural_singular(%0,%1,%2) ((%0) == 1)?((#%1)):((#%2))
// REACTION TEST AWARDS:
#define AWARD_CASH 0
#define AWARD_SCORE 1
// COLORS:
#define COLOR_REACTION_TEST 0x7800FFFF
// ARRAYS AND ENUMERATORS:
static const aCharacters[MAX_CHARACTERS][] =
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
};
// VARIABLES:
// GENERAL:
new gReactionPhrase[MAX_LENGTH + 1],
gReactionAwards[MAX_AWARDS];
// STATES:
new bool:sReactionTest = false;
// TIMERS:
new gtmReactionTest;
// MAIN:
main()
{
print("Development Mode: reaction_tests.amx");
}
// CALLBACKS:
public OnGameModeInit()
{
ReactionTestsInit();
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerText(playerid, text[])
{
if(sReactionTest)
{
if(strcmp(text, gReactionPhrase, true) == 0)
{
new string[144];
format(string, sizeof(string), "[REACTION TEST] %s (%d) won the reaction test, a new one will start soon!", PlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_REACTION_TEST, string);
format(string, sizeof(string), "Phrase: %s, Awards: $%s and %s %s.", gReactionPhrase, ConvertToAmount(gReactionAwards[AWARD_CASH]), \
ConvertToAmount(gReactionAwards[AWARD_SCORE]), plural_singular(gReactionAwards[AWARD_SCORE], "score point", "score points"));
SendClientMessageToAll(COLOR_REACTION_TEST, string);
for(new i = 0; i < MAX_AWARDS; i ++)
{
if(gReactionAwards[i] == 0) continue;
switch(gReactionAwards[i])
{
case AWARD_CASH: GivePlayerMoney(playerid, gReactionAwards[AWARD_CASH]);
case AWARD_SCORE: GivePlayerScore(playerid, gReactionAwards[AWARD_SCORE]);
}
gReactionAwards[i] = 0;
}
strdel(gReactionPhrase, 0, MAX_LENGTH);
sReactionTest = false;
}
}
return 1;
}
// COMMANDS:
CMD:reactiontests(playerid, params[])
{
if(!sReactionTest)
{
ReactionTestsInit();
SendClientMessage(playerid, COLOR_REACTION_TEST, "You have enabled the reaction tests.");
}
else
{
ReactionTestsExit();
SendClientMessage(playerid, COLOR_REACTION_TEST, "You have disabled the reaction tests.");
}
return 1;
}
CMD:reactiontestsstate(playerid, params[])
{
if(!sReactionTest) SendClientMessage(playerid, COLOR_REACTION_TEST, "The current reaction test isn't rolling or reaction tests are disabled.");
else SendClientMessage(playerid, COLOR_REACTION_TEST, "The current reaction test is still rolling.");
return 1;
}
// FUNCTIONS:
stock ReactionTestsInit()
{
KillTimer(gtmReactionTest);
gtmReactionTest = SetTimer("ReactionTest", INTERVAL_TIME, true);
}
stock ReactionTestsExit()
{
KillTimer(gtmReactionTest);
sReactionTest = false;
}
function ReactionTest()
{
new string[144], selected[2];
strdel(gReactionPhrase, 0, MAX_LENGTH);
gReactionAwards[AWARD_CASH] = RandomBetween(1000, 25000);
gReactionAwards[AWARD_SCORE] = RandomBetween(1, 3);
for(new i = 0; i < MAX_LENGTH; i ++)
{
selected = aCharacters[random(MAX_CHARACTERS)];
strcat(gReactionPhrase, selected);
}
format(string, sizeof(string), "[REACTION TEST] The first one to type %s wins $%s and %s %s.", gReactionPhrase, ConvertToAmount(gReactionAwards[AWARD_CASH]), \
ConvertToAmount(gReactionAwards[AWARD_SCORE]), plural_singular(gReactionAwards[AWARD_SCORE], "score point", "score points"));
SendClientMessageToAll(COLOR_REACTION_TEST, string);
sReactionTest = true;
}
stock ConvertToAmount(value)
{
new string[128], count = -1;
valstr(string, value);
for(new i = strlen(string); i > 0; i--)
{
count++;
if(count == 3)
{
strins(string, ",", i);
count = 0;
}
}
return string;
}
stock RandomBetween(minimum, maximum)
{
new selected = random(maximum - minimum) + minimum;
return selected;
}
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
stock GivePlayerScore(playerid, score) return SetPlayerScore(playerid, GetPlayerScore(playerid) + score);