Author Topic: Need scripting help!  (Read 9933 times)

0 Members and 1 Guest are viewing this topic.

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Need scripting help!
« on: August 21, 2014, 05:25:57 am »
I need help on the following things :

Q : I want to make custom health values for pickups,for example,a life icon gives 50 HP.

Q : My commands won't work.I typed the commands but nothing happened!

Q : I want to restrict other teams from picking up specific icons.For example,team Tommy can't pick up the armor,only team  Diaz can.

I need real quick help on this,please include the script codes (like SetPlayerHealth) in your comments.
Thanks.
« Last Edit: August 21, 2014, 04:59:14 pm by RookieCookie »

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #1 on: August 21, 2014, 04:59:54 pm »
I really need quick help,my script's deadline is coming soon.

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Need scripting help!
« Reply #2 on: August 22, 2014, 03:34:08 pm »
1.
Code: [Select]
public OnPickedUp(pickupid, playerid)//a function that is called once player picks something up
{
    if(pickupid == ID)//replace the "ID" with the id of a pickup you want to act
    {
        new Float:ph;//creating a variable to store player health in
        GetPlayerHealth(playerid, ph);//by this we get hp of a player who picked up the pickup and store it in "ph"
        SetPlayerHealth(playerid, ph + 50);//by ph + 50 we increase player's hp by 50 points
    }
    return 1;
}

2. Post here the code including your command

3. Make a check to make sure that Diaz team picked the pickup up. :D

Code: [Select]
public OnPickedUp(pickupid, playerid)
{
    if(GetPlayerTeam(playerid) == Diaz)//replace "Diaz" with your ID you gave to Diaz team.
    {
        //declare here what you want the pickup to do to diaz team players once one of them picks it up.
    }
}


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #3 on: August 22, 2014, 03:36:13 pm »
My commands :

Quote
public OnPlayerCommandText(playerid, cmdtext[])
{
   if (strcmp(cmdtext," engineoff ", true)==0)
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      KillVehicleEngine(vehicleid); // Engine off
      SendClientMessage(playerid,COLOR_WHITE,"Car engine turned off,re-enter the vehicle to restart it.");
       return 1;
   }
   if (strcmp(cmdtext," lightson ",true)==0)
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      SetVehicleLights(vehicleid,1); // Lights on
      SendClientMessage(playerid,COLOR_WHITE,"Car headlights turned on");
      return 1;
   }
   else if (strcmp(cmdtext," lightsoff ",true)==0)
   {
       new vehicleid = GetPlayerVehicleID(playerid);
       SetVehicleLights(vehicleid,0); // Lights off
       SendClientMessage(playerid,COLOR_WHITE,"Car headlights turned off");
       return 1;
    }
    if (strcmp(cmdtext," wakeup ",true)==0)
   {
        TogglePlayerControllable(playerid,1);
       SendClientMessage(playerid,COLOR_WHITE,"You are now awake!");
       return 1;
    }
   return 1;
}

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #4 on: August 22, 2014, 03:37:28 pm »
What code should I put if I don't want the pickup to work for team Tommy?

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Need scripting help!
« Reply #5 on: August 22, 2014, 03:45:55 pm »
What code should I put if I don't want the pickup to work for team Tommy?

if(GetPlayerTeam(playerid) != Tommy)//Your Tommy team ID instead of "Tommy"


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Need scripting help!
« Reply #6 on: August 22, 2014, 03:47:32 pm »
My commands :

Quote
public OnPlayerCommandText(playerid, cmdtext[])
{
   if (strcmp(cmdtext," engineoff ", true)==0)
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      KillVehicleEngine(vehicleid); // Engine off
      SendClientMessage(playerid,COLOR_WHITE,"Car engine turned off,re-enter the vehicle to restart it.");
       return 1;
   }
   if (strcmp(cmdtext," lightson ",true)==0)
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      SetVehicleLights(vehicleid,1); // Lights on
      SendClientMessage(playerid,COLOR_WHITE,"Car headlights turned on");
      return 1;
   }
   else if (strcmp(cmdtext," lightsoff ",true)==0)
   {
       new vehicleid = GetPlayerVehicleID(playerid);
       SetVehicleLights(vehicleid,0); // Lights off
       SendClientMessage(playerid,COLOR_WHITE,"Car headlights turned off");
       return 1;
    }
    if (strcmp(cmdtext," wakeup ",true)==0)
   {
        TogglePlayerControllable(playerid,1);
       SendClientMessage(playerid,COLOR_WHITE,"You are now awake!");
       return 1;
    }
   return 1;
}

Are you sure all the commands don't work?


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #7 on: August 22, 2014, 03:48:04 pm »
I typed commands like /c wakeup and nothing happened.

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Need scripting help!
« Reply #8 on: August 22, 2014, 04:03:55 pm »
Code: [Select]
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext,"engineoff", true)==0)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        KillVehicleEngine(vehicleid); // Engine off
        SendClientMessage(playerid,0xFFFFFFFF,"Car engine turned off,re-enter the vehicle to restart it.");
        return 1;
    }
    if (strcmp(cmdtext,"lightson",true)==0)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehicleLights(vehicleid,1); // Lights on
        SendClientMessage(playerid,0xFFFFFFFF,"Car headlights turned on");
        return 1;
    }
    if (strcmp(cmdtext,"lightsoff",true)==0)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehicleLights(vehicleid,0); // Lights off
        SendClientMessage(playerid,0xFFFFFFFF,"Car headlights turned off");
        return 1;
    }
    if (strcmp(cmdtext,"wakeup",true)==0)
    {
TogglePlayerControllable(playerid,1);
        SendClientMessage(playerid,0xFFFFFFFF,"You are now awake!");
        return 1;
}
    return 1;
}

Guess what was the problem? You typed " " (space) before and after each word in commands, like " lightson " instead of "lightson". Also, I'd recommend that you use more checks, and, tbh, I don't find /c wakeup useful.


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline [NYB]fast:p

  • Street Thug
  • *
  • Posts: 28
    • View Profile
Re: Need scripting help!
« Reply #9 on: August 26, 2014, 09:34:08 am »
not work!!!

Offline NeskWriter

  • Crime Boss
  • ****
  • Posts: 355
    • View Profile
Re: Need scripting help!
« Reply #10 on: August 26, 2014, 11:57:09 am »
not work!!!

?:D

He requested help, not posted his work.


-Funniest quotes-

Quote from: asad3man
i cant able to understand

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #11 on: August 26, 2014, 05:22:17 pm »
not work!!!

Actually,it does.
After using them my commands worked perfectly.

Offline RookieCookie

  • Street Thug
  • *
  • Posts: 24
    • View Profile
Re: Need scripting help!
« Reply #12 on: August 27, 2014, 03:44:00 pm »
Quote
error 076: syntax error in the expression, or invalid function call

[pawn] KillTimer(testtimer);[/pawn]