#1

Hi again, im trying to make a /nuke.

Ex: Admin /nuke 1

For all players: Player (1) has died from a mysterious explosion...

For the admin: You have nuked Player (1)

For the victim: You have died from a mysterious explosion.

Ive tried downloading peoples scripts and changing them but it just wont work. I also tried reading https://sampwiki.blast.hk/wiki/CreateExplosion, but idk how to make it explode a player. Please help!

Sorry for so much posts, once im told how i will remember!
Reply
#2

Try this

PHP Code:
if(strcmp(cmd"/nuke"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /nuke [playerid/PartOfName]");
                return 
1;
            }
            new 
play;
            new 
Float:slxFloat:slyFloat:slz;
            
play ReturnUser(tmp);
            if (
IsPlayerAdmin(playerid))
            {
                if(
IsPlayerConnected(play))
                {
                    if(
play != INVALID_PLAYER_ID)
                    {
                        
GetPlayerPos(playslxslyslz);
                        
CreateExplosion(slxslyslz-10.0611.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
SendClientMessage(play0x800080AA"You have died from a mysterious 
explosion"
);
                                                
SendClientMessageToAll(0x800080AA"Somebody has died from a mysterious Explosion");
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid0x800080AA"  You are not a bloody Admin !");
            }
        }
        return 
1;
    } 
Not Tested
Reply
#3

i want the Somebody to be a player. Like show the name of who got nuked
and i got alot of errors with that
Reply
#4

Rather simple if you ask me, try this which is an edit of Hal_Moore's


Stick this with your new's.

pawn Code:
new str[128];
new Nam[MAX_PLAYER_NAME];

And your OnPlayerCommandText

pawn Code:
if(strcmp(cmd, "/nuke", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /nuke [playerid/PartOfName]");
                return 1;
            }
            new play;
            new Float:slx, Float:sly, Float:slz;
            play = ReturnUser(tmp);
            if (IsPlayerAdmin(playerid))
            {
                if(IsPlayerConnected(play))
                {
                    if(play != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(play, slx, sly, slz);
                        CreateExplosion(slx, sly, slz-10.0, 6, 11.0);
                        CreateExplosion(slx, sly, slz-10.0, 7, 11.0);
                        CreateExplosion(slx, sly, slz-10.0, 7, 11.0);
                        SendClientMessage(play, 0x800080AA, "You have died from a mysterious  
explosion"
);
                                                SendClientMessageToAll(0x800080AA, "%s has died from a mysterious
Explosion"
,Nam);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, 0x800080AA, "  You are not a bloody Admin !");
            }
        }
        return 1;
    }
Try this, show me if you get any errors.

-nmader
Reply
#5

(3 : error 017: undefined symbol "cmd"
(42) : error 017: undefined symbol "tmp"
(42) : error 017: undefined symbol "strtok"
(43) : error 017: undefined symbol "tmp"
(45) : error 017: undefined symbol "COLOR_WHITE"
(50) : error 017: undefined symbol "ReturnUser"
(62) : warning 217: loose indentation
(62) : error 037: invalid string (possibly non-terminated string)
(62) : error 017: undefined symbol "has"
(62) : error 017: undefined symbol "died"
(62) : fatal error 107: too many error messages on one line



38: if(strcmp(cmd, "/nuke", true) == 0)
42: tmp = strtok(cmdtext, idx);
43: if(!strlen(tmp))
45: i can fix
50: play = ReturnUser(tmp);
62: SendClientMessage(play, 0x800080AA, "You have died from a
mysterious explosion");

my whole code:

pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

new str[128];
new Nam[MAX_PLAYER_NAME];

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmd, "/nuke", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /nuke [playerid/PartOfName]");
                return 1;
            }
            new play;
            new Float:slx, Float:sly, Float:slz;
            play = ReturnUser(tmp);
            if (IsPlayerAdmin(playerid))
            {
                if(IsPlayerConnected(play))
                {
                    if(play != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(play, slx, sly, slz);
                        CreateExplosion(slx, sly, slz-10.0, 6, 11.0);
                        CreateExplosion(slx, sly, slz-10.0, 7, 11.0);
                        CreateExplosion(slx, sly, slz-10.0, 7, 11.0);
                        SendClientMessage(play, 0x800080AA, "You have died from a mysteriousexplosion");
                                                SendClientMessageToAll(0x800080AA, "%s has died from a mysterious
Explosion"
,Nam);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, 0x800080AA, "  You are not a bloody Admin !");
            }
        }
        return 1;
    }
    return 0;
}
Reply
#6

PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[128];
    new 
tmp[128];
    if(
strcmp(cmd"/nuke"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /nuke [playerid/PartOfName]");
                return 
1;
            }
            new 
play;
            new 
Float:slxFloat:slyFloat:slz;
            
play ReturnUser(tmp);
            if (
IsPlayerAdmin(playerid))
            {
                if(
IsPlayerConnected(play))
                {
                    if(
play != INVALID_PLAYER_ID)
                    {
                        
GetPlayerPos(playslxslyslz);
                        
CreateExplosion(slxslyslz-10.0611.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
SendClientMessage(play0x800080AA"You have died from a mysterious explosion");
                        
SendClientMessageToAll(0x800080AA"Somebody has died from a mysterious Explosion");
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid0x800080AA"  You are not a bloody Admin !");
            }
        }
        return 
1;
    }
return 
0;

Not Tested yet, i ain't home.. If there's an error tell megh
Reply
#7

Quote:
Originally Posted by [RaZ]Hal_Moore
View Post
PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[128];
    new 
tmp[128];
    if(
strcmp(cmd"/nuke"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /nuke [playerid/PartOfName]");
                return 
1;
            }
            new 
play;
            new 
Float:slxFloat:slyFloat:slz;
            
play ReturnUser(tmp);
            if (
IsPlayerAdmin(playerid))
            {
                if(
IsPlayerConnected(play))
                {
                    if(
play != INVALID_PLAYER_ID)
                    {
                        
GetPlayerPos(playslxslyslz);
                        
CreateExplosion(slxslyslz-10.0611.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
CreateExplosion(slxslyslz-10.0711.0);
                        
SendClientMessage(play0x800080AA"You have died from a mysterious explosion");
                        
SendClientMessageToAll(0x800080AA"Somebody has died from a mysterious Explosion");
                    }
                }
            }
            else
            {
                
SendClientMessage(playerid0x800080AA"  You are not a bloody Admin !");
            }
        }
        return 
1;
    }
return 
0;

Not Tested yet, i ain't home.. If there's an error tell megh
one error: error 017: undefined symbol "ReturnUser"
pawn Code:
play = ReturnUser(tmp);
Reply
#8

Change ReturnUser to ReturnPlayerID and add this stock function to the bottom of your script:

pawn Code:
stock ReturnPlayerID(PlayerName[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new name[24];
            GetPlayerName(playerid, name, 24);
           
            if(strfind(pName(i),PlayerName,true)!=-1)
            {
                return i;
            }
        }
    }
    return INVALID_PLAYER_ID;
}
Reply
#9

why am i always getting errors? lol

error 017: undefined symbol "ReturnPlayerID"
pawn Code:
play = ReturnPlayerID(tmp);
error 029: invalid expression, assumed zero
pawn Code:
main()
error 017: undefined symbol "ReturnPlayerID" (and in my pawn 'stock' isnt blue like that)
pawn Code:
stock ReturnPlayerID(PlayerName[])
error 017: undefined symbol "pName"
pawn Code:
if(strfind(pName(i),PlayerName,true)!=-1)
Reply
#10

Sorry try this:

pawn Code:
stock ReturnPlayerID(PlayerName[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new name[24];
            GetPlayerName(i, name, 24);

            if(strfind(name(i),PlayerName,true)!=-1)
            {
                return i;
            }
        }
    }
    return INVALID_PLAYER_ID;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)