Little coding questions - For general minor queries 5

Quote:
Originally Posted by warduck
Посмотреть сообщение
Right now I have:
switch (reason)
{
case blabla: formatblablabla;
case bloblo: formatblobloblo;
return blublublu;
}

Am I able to use something like:
switch (reason)
{
case blablabla: formatblublu AND formatbleble
}

Always when I try to add two lines / codes after 1 case it will give me errors...
pawn Код:
switch (reason)
{
     case blablabla: {
          formatblublu;
          formatbleble;
     }
}
Just use curly braces as you normally would.
Reply

Thanks Calgon, worked out!

New issue is, I don't want to create a completely new interior enter/exit system nor disable the yellow markers, but I'd like to somehiow block the ammunations from being used. Any solution except mapping fugly gates around there which I do not want?
Reply

can somebody fix this command for me ?

Quote:

CMD:creategun(playerid, params[]) {
if(jobVariables[playerVariables[playerid][pJob]][jJobType] == 1)
{
if(playerVariables[playerid][pFreezeType] == 0) {
if(playerVariables[playerid][pJobDelay] == 0) {
switch(playerVariables[playerid][pJobSkill][0]) {
case 0 .. 10: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)","Select", "Cancel");
case 11 .. 20: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm pistol (250)","Select", "Cancel");
case 21 .. 30: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)","Select", "Cancel");
case 31 .. 40: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)","Select", "Cancel");
case 41 .. 50: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)","Select", "Cancel");
case 51 .. 60: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)","Select", "Cancel");
case 61 .. 70: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)","Select", "Cancel");
case 71 .. 80: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)","Select", "Cancel");
case 81 .. 90: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)","Select", "Cancel");
case 91 .. 100: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)\nSniper (2450)","Select", "Cancel");
default: ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)\nSniper (2450)\nSPAS12 (2550)\nKevlar Vest (1750)","Select", "Cancel");
}
}
else SendClientMessage(playerid, COLOR_GREY, "You must wait your reload time (5 minutes).");
}
else SendClientMessage(playerid, COLOR_GREY, "You can't do this while cuffed, tazed, or frozen.");
}
return 1;
}

when i type it nothing happen's, i tried to fix it but i can't do it...
Reply

Try this

pawn Код:
CMD:creategun(playerid, params[]) {
    if(jobVariables[playerVariables[playerid][pJob]][jJobType] == 1)
    {
        if(jobVariables[playerVariables[playerid][pJob]][jJobType] == 1 && playerVariables[playerid][pFreezeType] == 0 && 0 == playerVariables[playerid][pJobDelay]) {
            new str[500+1], tmp[256];
            switch(playerVariables[playerid][pJobSkill][0]) {
                case 0 .. 10: tmp = "";
                case 11 .. 20: tmp = "9mm pistol (250)";
                case 21 .. 30: tmp = "9mm Pistol (250)\nSilenced Pistol (300)";
                case 31 .. 40: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)";
                case 41 .. 50: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)";
                case 51 .. 60: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)";
                case 61 .. 70: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)";
                case 71 .. 80: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)";
                case 81 .. 90: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)";
                case 91 .. 100: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)\nSniper (2450)";
                default: tmp = "9mm Pistol (250)\nSilenced Pistol (300)\nShotgun (550)\nDesert Eagle (680)\nMP5 (850)\nMicro Uzi (900)\nAK-47 (1500)\nM4A1 (2000)\nSniper (2450)\nSPAS12 (2550)\nKevlar Vest (1750)";
            }
            str = "Katana (30)\nCane (30)\nPool Cue (33)\nBaseball Bat (35)\nShovel (50)\n";
            strcat(str, tmp);
            return ShowPlayerDialog(playerid, DIALOG_CREATEGUN, DIALOG_STYLE_LIST, "Weapon Selection", str, "Select", "Cancel");
        } else return SendClientMessage(playerid, COLOR_GREY, "You must wait your reload time (5 minutes).");
    } else return SendClientMessage(playerid, COLOR_GREY, "You can't do this while cuffed, tazed, or frozen.");
}
Edit:

And if you don't have any output just put prints everywhere to check where action stops
Reply

I have a little question: Is it possible to atach a object to an NPC, for example: like attach a chair to an npc and the chair can walk around (like a recorded npc)?
if yes can you tell some thing I have to use in script?
or is there something like: AttachObjectToNpc ? or something?
Reply

Код:
public OnPlayerUpdate(playerid)
{
new area = CreateDynamicRectangle(170.98, -152.42, 172.08, -153.79);
TogglePlayerDynamicArea(playerid, area, 1);
if IsPlayerInDynamicArea(playerid, area) *then
pObject[playerid] = CreatePlayerObject(playerid, 12923, 158.3594, -176.3047, 5.5703, 0, 0, 0, 300.0);
return 1;
}
What am I doing wrong? I want the object created once a player enters the area.
Reply

How can you create a new file numerically ordered. So you will have file called 2 created if file 1 exists?
Reply

pawn Код:
public OnPlayerConnect(playerid)
{
    static name[25];
    GetPlayerName(playerid,name,25);
    if(!strcmp(name,"Champ",true) || !strcmp(name,"Super_Champ",true) )
    {
        static str4[128]; // max size of a mensage is 128 cell it means you can type 128 caracters, so it's not neeeded put more than the max, you would be wasting memory.
        format(str4,sizeof(str4),"[24/7] Freeraom Server Owner {B8FFFF}Champ {2AFF00}Has Connected To Server !");
        SendClientMessageToAll(COLOR_SEAGREEN,str4);
    }
    return 1;
}

it's working for the name "Champ"... why not "Super one
Reply

It's not working as in nothing shows up, or it's not working because it always shows "Champ has connected"? It should work for both cases (even though the text is the same).
Reply

Hi ! I have some question, please answer

1. What is the difference between = and ==
2. What is the difference between + and +=
3. What is the difference between || and &&

Thanks
Reply

1. = is assignment, == is comparison operator
2.
pawn Код:
new i = 0;
i = i + 1;
//It's the same as
i += 1;
3. || - OR logic operator, && - AND logic operator.
pawn Код:
new test = (2 < 3 && 3 > 4); //Evaluates as false, because not all conditions are met
test = (2 < 3 || 3 > 4); //Evaluates as true, because one of the conditions is met
Reply

I have a question about incognito streamer: how can i attach a "dynamic" 3d text label to a player / vehicle?
Reply

Quote:
Originally Posted by RaZVaN ^ xD
Посмотреть сообщение
I have a question about incognito streamer: how can i attach a "dynamic" 3d text label to a player / vehicle?
You currently cannot do that. You may suggest that function in the streamer thread.
Reply

But the parameters "attachedplayer" and "attachedvehicle" ?

\\Later edit: If i put attachedplayer = 0 (just an example), the pos params will be offset params?
Reply

You can start by learning the SQL language itself for that is uniform across all platforms and scripting languages. I do, however, recommend to use R7 straight away. If you start with R6 and want to switch to R7 later on you're going to run into a big pile of trouble. Especially if you're relying on the return value of a function that retrieves something from the database.
Reply

I recommend you to start with SQLite then switch on to MySQL.
Reply

What causes the player to go shooting up, i.e. not able to spawn etc?
Reply

How can we loop a dialog. Like first want a input dialog and player enters a value. That value is stored in amount. And I want the 2nd dialog to show 'amount' times.
Reply

Quote:
Originally Posted by Virus.
Посмотреть сообщение
How can we loop a dialog. Like first want a input dialog and player enters a value. That value is stored in amount. And I want the 2nd dialog to show 'amount' times.
I don't think we've gotta loop for this.
pawn Код:
new itext = 0; //Create a variable inorder to get the input text and use it for other case. Starting it as zero as we want to store other text on dialog.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //When a dialog gets a response from one of the player.
{
  if(dialogid == 1) //If the response if for dialogid 1.
  {
   //As your post is talking about DIALOG_STYLE_INPUT, the dialog where we input text so lets take Dialog_style_input dialog.
   if(!response) //When player clicks 2nd button or while pressing ESC on keyboard. '!' refers to negative/wrong  response.
   { //Open brackets to execute functions for negative response.
    //Your functions here.
   }
   else //If it isn't a negative response, which means 'if(response)' and when '!' gets switched by else statement, you don't need to add 'if(response)'
   { //Open brackets to execute function for positive response or while clicking 1st button.
     itext = inputtext; //Here we made our itext variable as the text player entered on that dialog.
     //Other functions.
   }
  } //Closing the bracket which we've opened on 'if(dialogid)'.
  return 1; //Returns the functions.
  }
  return 0; //Like 'OnPlayerCommandText' we need to return 0 here too as returning the callback.
}
Now the variable 'itext' is contains the input text, and if you're using it in the case of players, change the variable 'new itext = 0;' to 'new itext[MAX_PLAYERS] = 0;' and while using it, use it as 'itext[playerid] = inputtext;' on dialog.
And now, the player's itext is the input text.
And you can use it, here's an example.
pawn Код:
CMD:enteredtextindialog(playerid,params[])
{
  new str[128];
  format(str, sizeof(str), "%s", itext[playerid]);
  SendClientMessage(playerid, 0xFF0000FF, str);
  return 1;
}
Hope this will give you an idea.
Reply

Thanks. But can we make a if statement for looping the dialogs.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)