SA-MP Forums Archive
Need help with my Jetpack command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with my Jetpack command. (/showthread.php?tid=402546)



Need help with my Jetpack command. - Magic_Time - 27.12.2012

I am trying to learn PAWNO.
I have errors compiling it
Код:
C:\Users\USER\Documents\samp03e_svr_R2_win32\pawno\Test.pwn(41) : error 001: expected token: ")", but found "["
C:\Users\USER\Documents\samp03e_svr_R2_win32\pawno\Test.pwn(41) : error 029: invalid expression, assumed zero
C:\Users\USER\Documents\samp03e_svr_R2_win32\pawno\Test.pwn(41) : warning 215: expression has no effect
C:\Users\USER\Documents\samp03e_svr_R2_win32\pawno\Test.pwn(41) : error 001: expected token: ";", but found "]"
C:\Users\USER\Documents\samp03e_svr_R2_win32\pawno\Test.pwn(41) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Also, I need to know if this command will work.

PHP код:
CMD:jetpack(playeridparams[])
{
if(
PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid"You're not an Administrator Level 2");
    {
    else if(
IsPlayerConnected(playerid) new targetid[MAX_PLAYER_NAME]; new string[256];
        {
        if(
sscanf(params,"u",targetid))SendClientMessage(playerid,"Usage: /jetpack (ID/Name);");
            {
            
GetPlayerName(playeridtargetid);
            
format(string,sizeof(string),"An administrator has given a jetpack to %s"targetid);
            
SendClientMessageToAll(-1string);
            
GivePlayerJetpack(targetid);
  return 
1;
 } 



Re: Need help with my Jetpack command. - XtremeR - 27.12.2012

This should work:

pawn Код:
CMD:jetpack(playerid, params[])
{
new targetid[MAX_PLAYER_NAME]; new string[256];
if(PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, "You're not an Administrator Level 2");
    {
    else if(IsPlayerConnected(playerid)
        {
        if(sscanf(params,"u",targetid)) SendClientMessage(playerid,"Usage: /jetpack (ID/Name);");
            {
            GetPlayerName(playerid, targetid);
            format(string,sizeof(string),"An administrator has given a jetpack to %s", targetid);
            SendClientMessageToAll(-1, string);
            GivePlayerJetpack(targetid);
  return 1;
 }



Re: Need help with my Jetpack command. - Magic_Time - 27.12.2012

I have the same errors.


Re: Need help with my Jetpack command. - zDevon - 27.12.2012

Here is the fixed version of your command.
pawn Код:
CMD:jetpack(playerid, params[])
{
    if(!PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, "You're not an Administrator Level 2");
    else {
            new targetid, new string[256], pname[MAX_PLAYER_NAME];
            if(sscanf(params,"u",targetid)) SendClientMessage(playerid,-1,"Usage: /jetpack (ID/Name)");
            {
                GetPlayerName(targetid,pname,26);
                format(string,sizeof(string),"An administrator has given a jetpack to %s", pname);
                SendClientMessageToAll(-1, string);
                SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
            }
    }
    return 1;
}
Changes and why I made them: I believe that's it, happy scripting!


Re : Re: Need help with my Jetpack command. - lelemaster - 27.12.2012

Quote:
Originally Posted by XtremeR
Посмотреть сообщение
This should work:

pawn Код:
CMD:jetpack(playerid, params[])
{
new targetid[MAX_PLAYER_NAME]; new string[256];
if(PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, "You're not an Administrator Level 2");
    {
    else if(IsPlayerConnected(playerid)
        {
        if(sscanf(params,"u",targetid)) SendClientMessage(playerid,"Usage: /jetpack (ID/Name);");
            {
            GetPlayerName(playerid, targetid);
            format(string,sizeof(string),"An administrator has given a jetpack to %s", targetid);
            SendClientMessageToAll(-1, string);
            GivePlayerJetpack(targetid);
  return 1;
 }
No it wont.

This will:

pawn Код:
CMD:jetpack(playerid, params[])
{
new targetidname[MAX_PLAYER_NAME],targetid; new string[256];
if(PlayerInfo[playerid][pAdmin] >= 2)
    {
    if(IsPlayerConnected(playerid))
        {
        if(!sscanf(params,"u",targetid))
            {
            GetPlayerName(targetid, targetidname, sizeof(targetidname));
            format(string,sizeof(string),"An administrator has given a jetpack to %s", targetidname);
            SendClientMessageToAll(-1, string);
            GivePlayerJetpack(targetid);
            }
            else return SendClientMessage(playerid,1,"Usage: /jetpack (ID/Name);");
        }
    }
    else return SendClientMessage(playerid, "You're not an Administrator Level 2");
  return 1;
 }
I just can't imagine how many errors you would get with XtremeR's code.
This will help him:

1-Missing closing brackets
2-You had a else if without and if statement above
3-Your returning messages would not do anything
4-GetPlayerName missed something
5-Forgot a closing ) after IsPlayerConnected
6-Where sscanf check the intered text, it would be inversed

EDIT:The man above me was faster, but anyways. Your last change, "GivePlayerJetpack" removed, maybe he has a function for it where it sets the special action in


Re: Need help with my Jetpack command. - Magic_Time - 27.12.2012

It worked now.
Can you help me to fix it_

I am newbie.
PHP код:
CMD:giveweapon(playeridparams[])
{
if(
IsPlayerConnected(playerid) new weapid; new targetid[MAX_PLAYER_NAME]; new string[256];
    {
    if(
sscanf(params,"ui",targetidweapid))SendClientMessage(playerid,-1,"Usage: /giveweapon (ID) (WeapID");
        {
        
GetPlayerName(playeridtargetid);
        
format(string,sizeof(string),"An administrator has given a weapon to %s"targetid);
        
SendClientMessageToAll(-1string);
        
GivePlayerWeapon(playeridweapid);
 return 
1;
  } 



Re : Need help with my Jetpack command. - lelemaster - 27.12.2012

Which line have errors?


Re: Need help with my Jetpack command. - Magic_Time - 27.12.2012

Thanks lelemaster.
Can you help me with this>
PHP код:
CMD:giveweapon(playeridparams[])
{
if(
IsPlayerConnected(playerid) new weapid; new targetid[MAX_PLAYER_NAME]; new string[256];
    {
    if(
sscanf(params,"ui",targetidweapid))SendClientMessage(playerid,-1,"Usage: /giveweapon (ID) (WeapID");
        {
        
GetPlayerName(playeridtargetid);
        
format(string,sizeof(string),"An administrator has given a weapon to %s"targetid);
        
SendClientMessageToAll(-1string);
        
GivePlayerWeapon(playeridweapid);
 return 
1;
  } 
Thanks in advance, and sorry, I'm learning.


Re : Re: Need help with my Jetpack command. - lelemaster - 27.12.2012

pawn Код:
CMD:giveweapon(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new weapid; new targetidname[MAX_PLAYER_NAME], targetid; new string[256];
    if(!sscanf(params,"ui",targetid, weapid))
        {
        GetPlayerName(targetid,targetidname, sizeof(targetidname));
        format(string,sizeof(string),"An administrator has given a weapon to %s", targetidname);
        SendClientMessageToAll(-1, string);
        GivePlayerWeapon(targetid, weapid, 1); // forgot ammo
        }
        else return SendClientMessage(playerid,-1,"Usage: /giveweapon (ID) (WeapID");
    }
 return 1;
  }



Re: Need help with my Jetpack command. - zDevon - 27.12.2012

You have the same mistakes in that command as you did with the last one. If you're 'learning', then read what I told you the first time and apply the same fixes with this command. That is how you will learn, not by copying and pasting.