CLEO Help Player name in chatmsg?

CLEO related
Status
Not open for further replies.

Donboo

New member
Joined
Mar 23, 2014
Messages
4
Reaction score
0
Code:
:cmd_118
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%d" 21@
then
    0B36: samp 1@ = get_player_nickname 21@
    0AF8: chatmsg "{CECECE}%s:{FFFFFF} loves you." -1 1@
else
    print "~r~/love<id>" 2000
end
SAMP.CmdRet()
will output " : loves you.". How can I display the player's name :surprised: ? Thanks
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
4
This should do it
Code:
:cmd_118
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%s" 21@v
then
    0B36: samp 1@v = get_player_nickname 21@v
    0AF8: chatmsg "{CECECE}%s:{FFFFFF} loves you." -1 1@v
else
    print "~r~/love<id>" 2000
end
SAMP.CmdRet()

"%s" means string and "v" after a variable allocates more memory.
so you have to do it like /command <playername>
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Donboo said:
will output " : loves you.". How can I display the player's name :surprised: ? Thanks

Your code should work, make sure your sanny builder format setting is set to 'as is' from the format tab in the options menu.

TehArgis said:
"%s" means string and "v" after a variable allocates more memory.
so you have to do it like /command <playername>

Uhh, what?
If you already have his name you wouldn't need to call 0B36, right?
Since 0B36 takes a int as parameter, that needs to be the player id not name.
@v strings can only hold 16 chars, what if a player name has more, like 18 or 20 or 24?
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
4
springfield said:
Uhh, what?
If you already have his name you wouldn't need to call 0B36, right?
Since 0B36 takes a int as parameter, that needs to be the player id not name.
@v strings can only hold 16 chars, what if a player name has more, like 18 or 20 or 24?
Yeah I know  he could just do it with ID but i thought it would be more cool to insert any name :3
Also SAMP has a char limit so it's not a problem :p


Sorry I was in a hurry, 0B36 should not be called as spring said :D
So if you want to insert any nickname that you want, that's the solution
Code:
:cmd_118
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%s" 21@v
then
   0AF8: chatmsg "{CECECE}%s:{FFFFFF} loves you." -1 21@v
else
   print "~r~/love<id>" 2000
end
SAMP.CmdRet()
If you want with ID, here it is
didn't test it tho :p
Code:
:cmd_118
SAMP.IsCommandTyped(20@)
if
0AD4: 20@ = scan_string 20@ format "%d" 21@v
then
   22@ = SAMP.GetActorHandleByPlayerID(21@)
   0B36: samp 1@v = get_player_nickname 22@v
   0AF8: chatmsg "{CECECE}%s:{FFFFFF} loves you." -1 1@v
else
   print "~r~/love<id>" 2000
end
SAMP.CmdRet()
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Yes, has a limit, but if my nick is "SPRINGFIELD_COOL_PLAYER" @v will only store part of the name, not the full name. That's not good.

Code:
:cmd
SAMP.IsCommandTyped(20@)
if 0AD4: $nul  = scan_string 20@ format "%s" 21@v //just to check if the input contains a string
then 0AF8: chatmsg "{CECECE}%s:{FFFFFF} loves you." -1 20@ //use the input pointer directly
else print "~r~/love<id>" 2000
end
SAMP.CmdRet()

And your second solution is partialy bad too, using 22@ = SAMP.GetActorHandleByPlayerID(21@) requires the player to be streamed, you can use
0B23: samp is_player_connected 21@ to check if the player is online and the nickname is valid.
 
  • Like
Reactions: MTM
Status
Not open for further replies.
Top