25.10.2013, 20:21
Gente como eu faзo aquela caixinha surpresa . de ganhar um dinheiro ... Sortiado ? sabem ? eu nao achei me ajudem ?
GivePlayerMoney(playerid,random(0b1100100) + 0b1100100); // Isso daria de 100 a 199
GivePlayerMoney(playerid,random(0b1100100) + 0b1); // Isso daria de 1 a 100
#include <a_Samp>
#include <Zcmd>
#include <DOF2>
#define Score 10
#define Money 100000
#define Surpresas "Surpresas/%s.ini"
new Nome[25];
new Fala[129];
new Surpresa[500];
new TimerSurprise[500];
stock SetPlayerSurprises(playerid,level)
{
Surpresa[playerid] = level;
return 1;
}
stock GetPlayerSurprises(playerid)
{
return Surpresa[playerid];
}
CMD:surpresas(playerid,params[])
{
if(IsPlayerInRangeOfPoint(playerid,1.0,1480.0,-1640.0,14.0))
{
if(GetPlayerSurprises(playerid) == 0)
{
GetPlayerName(playerid,Nome,sizeof(Nome));
format(Fala,sizeof(Fala),"%s adquiriu uma Surpresa! Para adquirir, vб atй o '$' no mapa.",Nome);
SendClientMessageToAll(0xFF8080AA,Fala);
SetPlayerScore(playerid,GetPlayerScore(playerid)+random(Score));
GivePlayerMoney(playerid,random(Money));
SetPlayerSurprises(playerid,60);
TimerSurprise[playerid] = SetTimerEx("ResetPlayerSurprises",60000,1,"i",playerid);
return 1;
}
else
{
SendClientMessage(playerid,0xBFBFBFAA,"Para adquirir outra Surpresa, espere uma Hora.");
return 1;
}
}
return 1;
}
public OnFilterScriptInit()
{
AddStaticPickup(1274,1,1480.0,-1640.0,14.0,0);
Create3DTextLabel("Surpresas\nTecle F e adquira a sua",0xFF8080AA,1480.0,-1640.0,14.0,10.0,0,0);
return 1;
}
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
public OnPlayerConnect(playerid)
{
SetPlayerMapIcon(playerid,54,1480.0,-1640.0,14.0,52,0,1);
GetPlayerName(playerid,Nome,sizeof(Nome));
format(Fala,sizeof(Fala),Surpresas,Nome);
if(DOF2_FileExists(Fala))
{
SetPlayerSurprises(playerid,DOF2_GetInt(Fala,"Tempo"));
TimerSurprise[playerid] = SetTimerEx("ResetPlayerSurprises",DOF2_GetInt(Fala,"Tempo"),1,"i",playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
if(GetPlayerSurprises(playerid) == 1)
{
GetPlayerName(playerid,Nome,sizeof(Nome));
format(Fala,sizeof(Fala),Surpresas,Nome);
if(!DOF2_FileExists(Fala))
{
DOF2_CreateFile(Fala);
DOF2_SetInt(Fala,"Tempo",GetPlayerSurprises(playerid));
DOF2_SaveFile();
return 1;
}
else
{
DOF2_SetInt(Fala,"Tempo",GetPlayerSurprises(playerid));
return 1;
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(newkeys == 16)
{
if(!IsPlayerInAnyVehicle(playerid))
{
cmd_surpresas(playerid,"");
return 1;
}
}
return 1;
}
public OnPlayerUpdate(playerid)
{
GetPlayerName(playerid,Nome,sizeof(Nome));
format(Fala,sizeof(Fala),Surpresas,Nome);
if(DOF2_FileExists(Fala))
{
DOF2_SetInt(Fala,"Tempo",GetPlayerSurprises(playerid));
DOF2_SaveFile();
}
else
{
if(GetPlayerSurprises(playerid) >= 1)
{
DOF2_CreateFile(Fala);
DOF2_SetInt(Fala,"Tempo",GetPlayerSurprises(playerid));
DOF2_SaveFile();
}
}
return 1;
}
forward ResetPlayerSurprises(playerid);
public ResetPlayerSurprises(playerid)
{
SetPlayerSurprises(playerid,GetPlayerSurprises(playerid)-1);
if(GetPlayerSurprises(playerid) == 0)
{
KillTimer(TimerSurprise[playerid]);
SendClientMessage(playerid,0xBFBFBFAA,"Adquira sua surpresa novamente! Vб atй o '$' no mapa.");
}
return 1;
}