Raised This Month: $ Target: $400
 0% 

New Code Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 05-15-2012 , 08:11   New Code Error
Reply With Quote #1

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <Hamsandwitch>



#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"


public plugin_init() {
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}a

public fwHamPlayerSpawnPost(iPlayer) {
if (is_user_alive(iPlayer)) {
// player spawned
print_center("YOU ARE RE SPAWNED,GOODLUCK! FOR THIS TIME")
print_center("DON'T GET FUCKED UP THIS TIME,RETREAT HELL!!")
}
PLUGIN_HANDLED
}




Error: Cannot read from file: "Hamsandwitch" on line 5
What to do??
Will this code do anything??

Last edited by Waleed; 05-16-2012 at 08:55. Reason: Missed something
Waleed is offline
Send a message via Skype™ to Waleed
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-15-2012 , 08:13   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #2

It's hamsandwich.

Also it should be:
PHP Code:
client_print(iPlayer,print_center,"your message here..."
Not just print_center.
__________________

Last edited by <VeCo>; 05-15-2012 at 08:14.
<VeCo> is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 05-15-2012 , 08:26   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #3

client_print(print_center "My message")

Error: Expected token: ",", but found "-string-" on line 23

If I add "ID",It says error about id...

what to do now ?
Waleed is offline
Send a message via Skype™ to Waleed
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 05-15-2012 , 08:38   Script Compiled,But Now working
Reply With Quote #4

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>



#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"


public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}

public fwhamplayerspawnpost(iplayer){
if (is_user_alive(iplayer))
{

client_print(iplayer,print_center,"YOU ARE RE SPAWNED,GOODLUCK! FOR THIS TIME")
client_print(iplayer,print_center,"DON'T GET FUCKED UP THIS TIME,RETREAT HELL!!")

}

else {

client_print(iplayer,print_center,"SCREWYOU,Y OU'RE DEAD AGAIN")
client_print(iplayer,print_center,"WAIT FOR RE-SPAWN")
}
}



I have compiled this script with no errors but its not working.
My plan was to show a message on respawn and on death,But not working.
Any suggestions,This is my first simple plugin,Help please..........
Waleed is offline
Send a message via Skype™ to Waleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-15-2012 , 08:40   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #5

There's no point in putting the else and the part after it, it will only cause errors.

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"

public plugin_init() 
{
    
RegisterHamHam_Spawn"player""fwHamPlayerSpawnPost");
}

public 
fwHamPlayerSpawnPostiPlayer 
{
    if( 
is_user_aliveiPlayer ) ) 
    {
        
// player spawned
        
client_printiPlayerprint_center"YOU ARE RE SPAWNED, GOODLUCK! FOR THIS TIME" );
        
client_printiPlayerprint_center"DON'T GET FUCKED UP THIS TIME, RETREAT HELL!!" );
    }

__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-15-2012 at 08:43. Reason: More to add after recent post
hornet is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-16-2012 , 03:33   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #6

Please learn to use [CODE][/CODE] tags around your code when posting.
__________________
fysiks is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 05-16-2012 , 08:02   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #7

In Ham_Spawn hooked as post, if the player is not alive, that means he's connecting (loading).
__________________
You can do anything you set your mind to, man.

Devil259 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-16-2012 , 08:07   Re: Error: Cannot read from file: "Hamsandwitch" on line 5
Reply With Quote #8

Quote:
Originally Posted by Devil259 View Post
In Ham_Spawn hooked as post, if the player is not alive, that means he's connecting (loading).
Aha! I've been looking for that answer for while I wondered why it caused errors if you didn't check if the player is alive.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-16-2012 at 08:07.
hornet is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 05-16-2012 , 08:39   New Code
Reply With Quote #9

I have changed the code,But still it isn't displaying anything,Any mistake here?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <Hamsandwich>

#define PLUGIN "HUD-Message"
#define VERSION "1.0"
#define AUTHOR "Waleed Baig"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	RegisterHam(Ham_Spawn,"players","fwhamplayerspawnpost",1)
	
}
public fwhamplayerspawnpost(iplayer)
{

 if (is_user_alive(iplayer))
{	
	set_hudmessage(0, 0, 255,0.5,0.5,0,6.0,30,0.5,0.5,4)
	show_hudmessage(iplayer, "I AM TRYING TO SHOW THIS MESSAGE")
	
}
}

Last edited by Waleed; 05-16-2012 at 08:40.
Waleed is offline
Send a message via Skype™ to Waleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-16-2012 , 09:07   Re: New Code Error
Reply With Quote #10

It's because you changed the entity name for the hook, which will be erroring ... Change it back to what I showed you.

You need to change:

PHP Code:
RegisterHam(Ham_Spawn,"players","fwhamplayerspawnpost",1
To

PHP Code:
RegisterHam(Ham_Spawn,"player","fwhamplayerspawnpost",1
And for a better message:

Change:

PHP Code:
set_hudmessage(00255,0.5,0.5,0,6.0,30,0.5,0.5,4
To

PHP Code:
set_hudmessage(00255,-1.0,0.25,0,6.0,30,0.5,0.5
And PLEASE stop using those [CODE] tags use [PHP] tags!!
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode