[Problem] Robbery / Checkpoint
#1

Problem: Okey, basically im trying to do a robbery in some shop as in Pizza ( Idlewood ). I've did this code and it seemed alright for me and in Pawn ir worked fine. I've tried testing it in my test server and the checkpoint is there and when i go in it a message pops up, this part is good. But when i try and do the command to rob the store nothing happens. I'll post pictures step by step too.

If you can help me fixing it please.

Pictures:

http://imgur.com/SNaqGHN,Vlqgosq,DhQ89qK,Jh9oM5P#1

Code:

pawn Код:
#include <a_samp>
#include <streamer>
#include <zcmd>

#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x33AA33AA
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#define COLOR_ORANGE 0xFFA500AA

new CP_pizza; // The name of the checkpoint add whatever you want :)
new ROBBING_PIZZA[MAX_PLAYERS]; //used when you rob
new pizzarobbedrecently =0; // to make the players wait before robbing more

stock GivePlayerScore( playerid, score ) SetPlayerScore( playerid, GetPlayerScore( playerid ) + score );

forward ServerRobbery();

public OnFilterScriptInit()
{
    SetTimer("ServerRobbery",1000,1);// Ticks every 1 second
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    CP_pizza = CreateDynamicCP( 378.2259, -114.4946, 1001.4922, 2.0, -1, -1, -1, 40.0);
    return 1;
}

public OnPlayerEnterDynamicCP(playerid, checkpointid) //Add this anywhere
{
   if(checkpointid == CP_pizza) //Checking if player is in the checkpoint "Tatoo"
   {
    SendClientMessage(playerid, COLOR_RED, "Start robbery by typing /robpizza"); //Sending message so that player knows that to rob. he must type this command
   }
   return 1;
}

CMD:robpizza(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
    {
        if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
        }
        ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
        pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
    }
    return 1;
}

public ServerRobbery()
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i)) // checking if player connected
            {
                //ROBBERIES
                if(ROBBING_PIZZA[i] > 1) // Checking if robbery time is above 1
                {
                    ROBBING_PIZZA[i] --; // Decreasing time
                    new time[20]; //adding time variable
                    format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
                    GameTextForPlayer(i,time,500,3); //shows gametext showing the time remaining for the robbery
                }
                if(ROBBING_PIZZA[i] == 1) // IF the timer reached 1
                {
                    new string[64], pName[MAX_PLAYER_NAME];// getting player name
                    GetPlayerName(i,pName,MAX_PLAYER_NAME);
                    SendClientMessage(i, COLOR_GREEN, "Robbery Complete"); //sending message to the player that robbery was complete
                    SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
                    ROBBING_PIZZA[i] =0; // RESET timer
                    new mrand =random(50000);
                    GivePlayerScore(i,1);
                    format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed a total of $%d from Well Stacked Pizza!",pName,i,mrand);
                    SendClientMessageToAll(COLOR_RED,string);
                    GivePlayerMoney(i, mrand);
                }
            }
        }
        return 1;
}

public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CP_pizza) // checking if the player is leaving the CP tatoo
    {
        if(ROBBING_PIZZA[playerid] >= 1) //checking if the person was robbing and his robbery timer was above 1
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]Robbery Failed"); //Error message that he failed
            ROBBING_PIZZA[playerid] =0; // Setting Robbing_tatoo to 0. to stop the counter
            return 1;
        }
    }
    return 1;
}

//    #pragma unused params // we dont need the params
Reply
#2

i think it should be like this...

pawn Код:
CMD:robpizza(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
    if(pizzarobbedrecently >=1) return SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); //checking if tatoo shop has been robbed recently and then stop the command

    ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
    pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
    return 1;
}
meanwhile your's is like this

pawn Код:
CMD:robpizza(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
    {
        if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
        }
        ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
        pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
    }
    return 1;
}
you don't need to add culry bracket after "if" statement with a "return"

Sorry for my bad english
Reply
#3

Still with the same problem man, arranged that but nothing still happens when i enter command.
Reply
#4

Should I get this interiors script too, maybe it's causing the problem?
Reply
#5

Use this:
pawn Код:
#include <a_samp>
#include <streamer>
#include <zcmd>

#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x33AA33AA
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#define COLOR_ORANGE 0xFFA500AA

new CP_pizza; // The name of the checkpoint add whatever you want :)
new ROBBING_PIZZA[MAX_PLAYERS]; //used when you rob
new pizzarobbedrecently =0; // to make the players wait before robbing more

stock GivePlayerScore( playerid, score ) SetPlayerScore( playerid, GetPlayerScore( playerid ) + score );

forward ServerRobbery();

public OnFilterScriptInit()
{
    SetTimer("ServerRobbery",1000,1);// Ticks every 1 second
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    CP_pizza = CreateDynamicCP( 378.2259, -114.4946, 1001.4922, 2.0, -1, -1, -1, 40.0);
    return 1;
}

public OnPlayerEnterDynamicCP(playerid, checkpointid) //Add this anywhere
{
   if(checkpointid == CP_pizza) //Checking if player is in the checkpoint "Tatoo"
   {
    SendClientMessage(playerid, COLOR_RED, "Start robbery by typing /robpizza"); //Sending message so that player knows that to rob. he must type this command
   }
   return 1;
}

CMD:robpizza(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
    {
        if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
        }
        ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
        pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
    format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
        GameTextForPlayer(i,time,1000,5);
    }
    return 1;
}

public ServerRobbery()
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i)) // checking if player connected
            {
                //ROBBERIES
                if(ROBBING_PIZZA[i] > 1) // Checking if robbery time is above 1
                {
                    ROBBING_PIZZA[i] --; // Decreasing time
                    new time[30]; //adding time variable
                    format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
                    GameTextForPlayer(i,time,1000,5); //shows gametext showing the time remaining for the robbery
                }
                if(ROBBING_PIZZA[i] == 1) // IF the timer reached 1
                {
                    new string[64], pName[MAX_PLAYER_NAME];// getting player name
                    GetPlayerName(i,pName,MAX_PLAYER_NAME);
                    SendClientMessage(i, COLOR_GREEN, "Robbery Complete"); //sending message to the player that robbery was complete
                    SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 1); //giving player 1 wanted level
                    ROBBING_PIZZA[i] =0; // RESET timer
                    new mrand =random(50000);
                    GivePlayerScore(i,1);
                    format(string,sizeof(string),"[ROBBERY] %s(%d) has robbed a total of $%d from Well Stacked Pizza!",pName,i,mrand);
                    SendClientMessageToAll(COLOR_RED,string);
                    GivePlayerMoney(i, mrand);
                }
            }
        }
        return 1;
}

public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CP_pizza) // checking if the player is leaving the CP tatoo
    {
        if(ROBBING_PIZZA[playerid] >= 1) //checking if the person was robbing and his robbery timer was above 1
        {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]Robbery Failed"); //Error message that he failed
            ROBBING_PIZZA[playerid] =0; // Setting Robbing_pizza to 0. to stop the counter
        }
    }
    return 1;
}
aka. http://pastebin.com/bfnPKD6n

NOTE: Avoid the usage of #pragma...
Reply
#6

Got these errors:

pawn Код:
filterscripts\robberyx2.pwn(65) : warning 217: loose indentation
filterscripts\robberyx2.pwn(65) : error 017: undefined symbol "time"
filterscripts\robberyx2.pwn(65) : error 017: undefined symbol "time"
filterscripts\robberyx2.pwn(65) : error 029: invalid expression, assumed zero
filterscripts\robberyx2.pwn(65) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Line:

pawn Код:
format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
In this part: [Error part]

pawn Код:
CMD:robpizza(playerid, params[])
{
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
    {
        if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
        {
            SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
        }
        ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
        pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
        Error part: format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[i]);
        GameTextForPlayer(i,time,1000,5);
    }
    return 1;
}
Reply
#7

pawn Код:
CMD:robpizza(playerid, params[])
{
    new time[30];
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
     {
           if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
           {
                  SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
           }
           ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
           pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
           format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[playerid]);
           GameTextForPlayer(i,time,1000,5);
     }
     return 1;
}
Reply
#8

Quote:
Originally Posted by biker122
Посмотреть сообщение
pawn Код:
CMD:robpizza(playerid, params[])
{
    new time[30];
    if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
     {
           if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
           {
                  SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
           }
           ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
           pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
           format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[playerid]);
           GameTextForPlayer(i,time,1000,5);
     }
     return 1;
}
Only error:

pawn Код:
filterscripts\robberyx2.pwn(67) : error 017: undefined symbol "i"
In this line:

GameTextForPlayer(i,time,1000,5);
Reply
#9

Can someone help pls
Reply
#10

pawn Код:
CMD:robpizza(playerid, params[])
{
     new time[30];
     if(!IsPlayerInDynamicCP(playerid, CP_pizza)) return SendClientMessage(playerid, COLOR_RED,"You are not in ....");
     {
               if(pizzarobbedrecently >=1) //checking if tatoo shop has been robbed recently
               {
                        SendClientMessage(playerid, COLOR_RED, "Well Stacked Pizza has been robbed recently"); // sending error message
               }
               ROBBING_PIZZA[playerid] = 60; // setting the robbery timer
               pizzarobbedrecently =180; // Time the players needs to wait for starting an another robbery in the same place
               format(time,sizeof(time),"Robbery Time: %d",ROBBING_PIZZA[playerid]);
               GameTextForPlayer(playerid,time,1000,5);
       }
       return 1;
}
Sorry, I keep forgetting to change something.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)