Setwep cmd help.

Started by [VM_U]Spectra.PhantoM^, Jan 18, 2016, 08:35 PM

Previous topic - Next topic

[VM_U]Spectra.PhantoM^

I builded it this far:
else if (cmd == "setwep")
{
local plr = GetPlayer(GetTok(text, " ", 1));
if ( !text ) MessagePlayer( "[#ffd700]Syntax: /"+ cmd +" <playername>", player );
if (PlayerIsAdmin)
{
plr.GiveWeapon( text.tofloat(), 999 );
Message("[#ff0000]-> [#FF0000]Admin [#ffffff]"+ player.Name +" gave "+ plr.Name +"");
}
}
but it gives me error:
AN ERROR HAS OCCURED [cannot convert the string]
CALLSTACK
*FUNCTION [onPlayerCommand()] Main.nut line [407]
LOCALS
[plr] INSTANCE
[plr] INSTANCE
[i] 2
[text] " ult spas"
[cmd] "setwep"
[player] INSTANCE
[this] TABLE
Help fast plz. Thanx
Wanna Talk To Me? Come At Irc #Jugo@LUNet

[VM_U]Spectra.PhantoM^

#1
Quote from: hotdogcat on Jan 19, 2016, 12:24 AMif (PlayerIsAdmin)

:palmface
thats a function i have. since im using RCON.so i dont use getlevel functions to check if player is admin.
Quote from: MatheuS on Jan 18, 2016, 09:33 PMplr.GiveWeapon( text.tofloat(), 999 );
wtf?
a random idea popped into my head.....
Wanna Talk To Me? Come At Irc #Jugo@LUNet

EK.IceFlake

wait a minute youre converting the text to a float WTF
and that playerisadmin wont work under any circumstances whatsoever.

MatheuS

#3
.tofloat
0.156
.tointeger
1 2 3 4 5 6
.tolower
Old name: Testing       New name: testing  //if you're using tolower
.toupper
Old name: blablabla        New name: BLABLABLA
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

#4
Quote from: NE.CrystalBlue on Jan 19, 2016, 11:54 AMwait a minute youre converting the text to a float WTF
and that playerisadmin wont work under any circumstances whatsoever.
Why not?
function onPlayerCommand( player, text, args ) {
local PlayerIsAdmin = false;
if ( getRconLevelThing( player ) > 2 ) {
   PlayerIsAdmin = true;
}

if ( PlayerIsAdmin ) {
print("Yes.");
}



The most obvious error in that snippet is the .tofloat(). You would want to use the .tointeger() function.
Make sure you validate the text a bit more first, though. Functions like IsNum should give you a pretty good idea.

(Also cleaned the topic up a bit. Replies like WTF? :facepalm and commit suicide wont help anyone. Don't post anything if you have nothing useful to post.)

[VM_U]Spectra.PhantoM^

Quote from: NE.CrystalBlue on Jan 19, 2016, 11:54 AMwait a minute youre converting the text to a float WTF
and that playerisadmin wont work under any circumstances whatsoever.
Its a functiones i have for the last time and IT WORKS MAN. i use it in meh server.
Wanna Talk To Me? Come At Irc #Jugo@LUNet

KAKAN

Quote from: {ultimatejugo] on Jan 21, 2016, 04:44 AM
Quote from: NE.CrystalBlue on Jan 19, 2016, 11:54 AMwait a minute youre converting the text to a float WTF
and that playerisadmin wont work under any circumstances whatsoever.
Its a functiones i have for the last time and IT WORKS MAN. i use it in meh server.
Try entering the ID instead of the name.
oh no

Williams

if ( cmd == "setwep" )
{
if ( GetLevel( player ) >= 5 )
{
   if ( text )
{
local plr = FindPlayer(GetTok(text, " ", 1));
local wep = GetTok( text, " ", 2 );
local ammo = GetTok( text, " ", 3 );
if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 30)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 31)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 33)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else
{
plr.SetWeapon( GetWeaponID( wep ), ammo.tointeger());
MessagePlayer( "Admin "+ player.Name + " gave you a " + GetWeaponName( GetWeaponID( wep ) ) +". Ammo: " + ammo + ".",plr );
MessagePlayer( "Giving " + plr.Name + " a " + GetWeaponName( GetWeaponID( wep ) ) +". Ammo: " + ammo + ".",player );
}
}
else MessagePlayer( "USAGE: /setwep [ Nick/ID ] [ Weapon Name ] [ Ammo ]",player );
}
                    else MessagePlayer ( "Error - You need to be at least level 6 to use that command.", player );
}

Try that cmd ... Its tested.
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

[VM_U]Spectra.PhantoM^

Quote from: Williams on Jan 21, 2016, 10:36 AM if ( cmd == "setwep" )
{
if ( GetLevel( player ) >= 5 )
{
   if ( text )
{
local plr = FindPlayer(GetTok(text, " ", 1));
local wep = GetTok( text, " ", 2 );
local ammo = GetTok( text, " ", 3 );
if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 30)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 31)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else if ((GetLevel( player ) !=10 && GetWeaponID(wep) == 33)) MessagePlayer( "You need to be admin level 10 to spawn that weapon.", player );
else
{
plr.SetWeapon( GetWeaponID( wep ), ammo.tointeger());
MessagePlayer( "Admin "+ player.Name + " gave you a " + GetWeaponName( GetWeaponID( wep ) ) +". Ammo: " + ammo + ".",plr );
MessagePlayer( "Giving " + plr.Name + " a " + GetWeaponName( GetWeaponID( wep ) ) +". Ammo: " + ammo + ".",player );
}
}
else MessagePlayer( "USAGE: /setwep [ Nick/ID ] [ Weapon Name ] [ Ammo ]",player );
}
                    else MessagePlayer ( "Error - You need to be at least level 6 to use that command.", player );
}

Try that cmd ... Its tested.
Dammit i didnt think of GetWeaponID( wep ) just had .tointeger ideas. Problem solved thanx
Wanna Talk To Me? Come At Irc #Jugo@LUNet

KAKAN

Quote from: {ultimatejugo] on Jan 22, 2016, 08:37 AMDammit i didnt think of GetWeaponID( wep ) just had .tointeger ideas. Problem solved thanx
Off: Can you even think?
oh no

[VM_U]Spectra.PhantoM^

Quote from: KAKAN on Jan 22, 2016, 03:53 PM
Quote from: {ultimatejugo] on Jan 22, 2016, 08:37 AMDammit i didnt think of GetWeaponID( wep ) just had .tointeger ideas. Problem solved thanx
Off: Can you even think?
Yes i can. No Rude Jestures PL0X
Wanna Talk To Me? Come At Irc #Jugo@LUNet