Jump to content

Cerere Tutorial


NoNamed

Recommended Posts

Neata SA-MP.Ro, am si eu nevoie de putin ajutor din partea voastra :

 

Descriere tutorial: Am comanda /robbank si vreau ca banca sa poata fi spart la ora fixa doar de un singur  player, apoi cand ceilalti dau /robbank sa le spuna ca banca se poate sparge o data la o ora ... Problema mea este  ca nu stiu cum sa fac sa poata fi sparta numai la ora fixa si de un singur playeri, nu de toata lumea ...

Link to comment
Share on other sites

public OnGameModeInit()
{
SetTimer("RobBank", 1000 * 60, 1);
}

forward RobBank(plyerid);
public RobBank(playerid)
{
new ora, minute;
gettime(ora, minute);
if(minute == 0)
{
 // your command
}
else
{
SendClientMessage(playerid, -1, "Banca: A fost dat un rob, nu mai poti da altul acum. Revino peste 1 ore.");
}
}

Nu stiu daca functioneaza dar poti incerca 

"Mulţi programatori buni fac programare nu pentru că se aşteaptă să câştige bani sau să fie lăudaţi de public, ci pentru că e amuzant să programezi." - Linus Torvalds

Link to comment
Share on other sites

Sunt cativa pasi minori de facut.

 

In primul rand pune la OnPlayerCommandText unde ai tu comanda /rob [pawn]RobBank(playerid);[/pawn]

 

Acum undeva in Gamemode pui asta

 

[pawn]

new BancaAFostJefuitaLaFix = 0;

 

forward JefuiesteBanca(plyerid);
public JefuiesteBanca(playerid)
{
    new Ora, Minute, Secunde;
    gettime(Ora, Minute, Secunde);
    
    if(Minute == 0)
        BancaAFostJefuita = 0;
        
    if(Minute == 0 && BancaAFostJefuita == 0)
    {
        // Script-ul tau
        BancaAFostJefuita = 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "Banca: A fost dat un rob, nu mai poti da altul acum. Revino peste 1 ora.");
    }
}
[/pawn]

 

[pawn]if(Minute == 0)
        BancaAFostJefuita = 0;[/pawn]

 

Aici verifici daca e minutul 0 si ii setezi ca banca nu a fost jefuita. (O sa zici ca de ce am pus aici acesta, l-am pus pentru ca daca nu folosesti un Timer Fix acesta se poate executa cu intarziere, deci ... )

 

[pawn]new Ora, Minute, Secunde;
gettime(Ora, Minute, Secunde);[/pawn] aici ii iei ora, minutul si secundele de pe server.

 

[pawn] if(Minute == 0 && BancaAFostJefuita == 0)
    {
        // Script-ul tau

        BancaAFostJefuita = 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "Banca: A fost dat un rob, nu mai poti da altul acum. Revino peste 1 ora.");
    }[/pawn]

 

Aici verifici daca este minutul 0 si banca nu a fost jefuita, daca a fost ii trimiti mesajul respectiv.

Link to comment
Share on other sites

Uite ce erori imi da :

D:SAMPSAMP.CVL.ROgamemodesCVL.pwn(7361) : error 033: array must be indexed (variable "BancaAFostJefuita")
D:SAMPSAMP.CVL.ROgamemodesCVL.pwn(22847) : error 033: array must be indexed (variable "BancaAFostJefuita")
D:SAMPSAMP.CVL.ROgamemodesCVL.pwn(22869) : error 033: array must be indexed (variable "BancaAFostJefuita")
D:SAMPSAMP.CVL.ROgamemodesCVL.pwn(22874) : error 023: array assignment must be simple assignment
D:SAMPSAMP.CVL.ROgamemodesCVL.pwn(22874) : warning 215: expression has no effect
Pawn compiler 3.2.3664     Copyright (c) 1997-2006, ITB CompuPhase
 
 
4 Errors.

Prima data cand mi-a dat aceste erori am pus dupa fiecare "BancaAFostJefuita" [playerid] dar cand intram in joc am dat prima data rob si a mers iar la 00 cand am vrut sa dau iar zicea ca trebuie sa astept o ora ... asa ca am scos [playerid] din fata...

 

Uite cum am facut variabila (m-a pus sa schimb din public in stock)

 

 

stock JefuiesteBanca(playerid)
{
    new string[128];
new sendername[MAX_PLAYER_NAME];
   new Ora, Minute, Secunde;
   gettime(Ora, Minute, Secunde);
    if(Minute == 0)
    BancaAFostJefuita = 0;
    if(Minute == 0 && BancaAFostJefuita == 0)
{
new leader = PlayerInfo[playerid][pLeader];
   new member = PlayerInfo[playerid][pMember];
     if(member==1 || member==2 || member==3 )
      {
       SendClientMessage(playerid, COLOR_GREEN, "Nu poti jefui banca !");
         return 1;
        }
        else if(leader==1 || leader==2 || leader==3 )
        {
         SendClientMessage(playerid, COLOR_LIGHTGREEN, "Nu poti jefui banca !");
          return 1;
        }
        if(PlayerInfo[playerid][pLevel] < 3)
        {
       SendClientMessage(playerid, COLOR_LIGHTGREEN, "   Trebuie sa ai level 3!");
         return 1;
        }
if(BancaAFostJefuita == 0)
   {
GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string,sizeof(string)," **Banca a fost jefuita de catre %s, acesta este in mare pericol !**" , sendername);
    SendClientMessageToAll(COLOR_YELLOW, string);
  BancaAFostJefuita +=1;
SetPlayerCheckpoint(playerid, 2377.4697,-2015.6392,14.3964, 3.0);
    SetPlayerAttachedObject(playerid, 3, 1550, 1, 0.1, -0.3, 0, 0, 40, 0, 1, 1, 1);
       WantedPoints[playerid] +=10; SetPlayerCriminal(playerid,255, "Robbing the BANK!");
 
 
}
BancaAFostJefuita = 1;
}
    else
  {
    SendClientMessage(playerid, COLOR_BLUE, "Banca poate fi sparta o data la o ora.");
  }
}
Edited by NoNamed
Link to comment
Share on other sites

Deja ai variabila BancaAFostJefuita. Atunci inlocuieste tot ce ti-am dat eu cu astea.
 
[pawn]new BancaAFostJefuitaLaFix = 0;
 

forward JefuiesteBanca(plyerid);
public JefuiesteBanca(playerid)
{
  new Ora, Minute, Secunde;
  gettime(Ora, Minute, Secunde);
 
   if(Minute == 0)
    BancaAFostJefuitaLaFix = 0;
 
  if(Minute == 0 && BancaAFostJefuitaLaFix == 0)
  {
    // Script-ul tau
    BancaAFostJefuitaLaFix = 1;
  }
  else
  {
    SendClientMessage(playerid, -1, "Banca: A fost dat un rob, nu mai poti da altul acum. Revino peste 1 ora.");
  }
}[/pawn]

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.