Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: RookieCookie on August 21, 2014, 05:25:57 am

Title: Need scripting help!
Post by: RookieCookie 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.
Title: Re: Need scripting help!
Post by: RookieCookie on August 21, 2014, 04:59:54 pm
I really need quick help,my script's deadline is coming soon.
Title: Re: Need scripting help!
Post by: NeskWriter 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.
    }
}
Title: Re: Need scripting help!
Post by: RookieCookie 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;
}
Title: Re: Need scripting help!
Post by: RookieCookie 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?
Title: Re: Need scripting help!
Post by: NeskWriter 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"
Title: Re: Need scripting help!
Post by: NeskWriter 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?
Title: Re: Need scripting help!
Post by: RookieCookie on August 22, 2014, 03:48:04 pm
I typed commands like /c wakeup and nothing happened.
Title: Re: Need scripting help!
Post by: NeskWriter 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.
Title: Re: Need scripting help!
Post by: [NYB]fast:p on August 26, 2014, 09:34:08 am
not work!!!
Title: Re: Need scripting help!
Post by: NeskWriter on August 26, 2014, 11:57:09 am
not work!!!

?:D

He requested help, not posted his work.
Title: Re: Need scripting help!
Post by: RookieCookie on August 26, 2014, 05:22:17 pm
not work!!!

Actually,it does.
After using them my commands worked perfectly.
Title: Re: Need scripting help!
Post by: RookieCookie on August 27, 2014, 03:44:00 pm
Quote
error 076: syntax error in the expression, or invalid function call

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