Raised This Month: $ Target: $400
 0% 

spawn, beginner


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-08-2013 , 00:10   spawn, beginner
Reply With Quote #1

How can I make it work?

I am a beginner, so don't judge me please... and help me...

I need like... If a person types "/spawn" in the chat he/she can spawn, but only 2 time per round, and I have no idea how to make it...

and look at my bad, really bad scripting: ()

PHP Code:
public plugin_init()

    
register_plugin("Vn""0.1""Alex")
    
register_clcmd("say /spawn","user_spawn")

PHP Code:
public user_spawn(id){
for(new 
02i++ )
    {
    
player players[i];
    if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
    {
        
spawn(id)
    }
    }


Last edited by leonardo_; 02-08-2013 at 00:13.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 02-08-2013 , 01:26   Re: spawn, beginner
Reply With Quote #2

First, use Ham Sandwich spawn function. It better then using the fun function

(Note: Fakemeta dll-spawn is for entity, not for players - I checked at my server and it doesn't spawn me, but it show that i'm alive and no one can kill me).

You need to create a global variable that his size is 33 (32 cells, from 0 to 32)
And then read this: https://forums.alliedmods.net/showthread.php?t=42159

Use the round start event
There, use get_players (or just looping with get_maxplayers) and for every player reset the variable cell like that:
PHP Code:
for(new 1<= get_maxplayers(); i++) variable_name[i] = 0
Sorry i cann't help u more cuz i'm at school lol
__________________

Last edited by simanovich; 02-08-2013 at 01:27. Reason: opps
simanovich is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-08-2013 , 01:31   Re: spawn, beginner
Reply With Quote #3

Quote:
Originally Posted by simanovich View Post
First, use Ham Sandwich spawn function. It better then using the fun function

(Note: Fakemeta dll-spawn is for entity, not for players - I checked at my server and it doesn't spawn me, but it show that i'm alive and no one can kill me).

You need to create a global variable that his size is 33 (32 cells, from 0 to 32)
And then read this: https://forums.alliedmods.net/showthread.php?t=42159

Use the round start event
There, use get_players (or just looping with get_maxplayers) and for every player reset the variable cell like that:
PHP Code:
for(new 1<= get_maxplayers(); i++) variable_name[i] = 0
Sorry i cann't help u more cuz i'm at school lol
yes, I just found out about that function! It's actually is much better then the other one.
Thank you!

I'll try to make something then post it here and yo tell me ether it works or not, ok?
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 02-08-2013 , 02:00   Re: spawn, beginner
Reply With Quote #4

Quote:
Originally Posted by leonardo_ View Post
yes, I just found out about that function! It's actually is much better then the other one.
Thank you!

I'll try to make something then post it here and yo tell me ether it works or not, ok?
Compare you'r code with that code (I didn't test it, but it should work):
PHP Code:
#include <amxmodx>
#include <hamsandwich>

new g_SpawnTimes[33];
new 
g_MaxPlayers// It's just to reset

public plugin_init(){
    
register_clcmd("say /spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players
}

public 
Event_NewRound(){
    for (new 
1<= g_MaxPlayersi++)
        
g_SpawnTimes[i] = 0// Reset the variable cells to 0
}

public 
cmd_spawn(client){
    if (
g_SpawnTimes[client] > 2)
    {
        
client_print(client,print_chat,"[AMXX] You can respawn only 2 times per round"); // Message to client
        
return; // blocks the function so we won't respawn
    
}

    else if (
is_user_alive(client))
    {
        
client_print(client,print_chat,"[AMXX] Dude, you'r alive!");
        return;
    }
    
    
ExecuteHam(Ham_CS_RoundRespawn,client); // Respawn the client with Ham
    
client_print(client,print_chat,"[AMXX] You just respawned now lol"); // Send a message to client that he just respawned

__________________

Last edited by simanovich; 02-08-2013 at 02:46. Reason: Whoops
simanovich is offline
leonardo_
Member
Join Date: Nov 2012
Location: Moscow, right now in Vic
Old 02-08-2013 , 02:11   Re: spawn, beginner
Reply With Quote #5

Quote:
Originally Posted by simanovich View Post
Compare you'r code with that code (I didn't test it, but it should work):
PHP Code:
public plugin_init(){
    
register_clcmd("/spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players

->

PHP Code:
register_clcmd("say /spawn","cmd_spawn"); 
but yes, it works!

and what does that mean?

PHP Code:
register_event("HLTV""Event_NewRound""a""1=0""2=0"); 
that part:
PHP Code:
 "a""1=0""2=0"); 

Last edited by leonardo_; 02-08-2013 at 02:18.
leonardo_ is offline
Send a message via ICQ to leonardo_ Send a message via Skype™ to leonardo_
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 02-08-2013 , 02:45   Re: spawn, beginner
Reply With Quote #6

Quote:
Originally Posted by leonardo_ View Post
PHP Code:
public plugin_init(){
    
register_clcmd("/spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players

->

PHP Code:
register_clcmd("say /spawn","cmd_spawn"); 
but yes, it works!

and what does that mean?

PHP Code:
register_event("HLTV""Event_NewRound""a""1=0""2=0"); 
that part:
PHP Code:
 "a""1=0""2=0"); 
About the first: Yap, I forgot to write "say"
About the second:
"a" is flag that says to amxx that it's a global event.
"1=0" means that the first param must be 0.
"2=0" means that the second param must be 0.

From amxmodx.inc:
PHP Code:
/* Registers event on which a given function will be called
* Flags:
* "a" - global event.
* "b" - specified.
* "c" - send only once when repeated to other players.
* "d" - call if is send to dead player.
* "e" - to alive.
* NOTE: Due to a long-standing bug that would break compatibility with old plugins,
*       the client id should be checked for alive/dead state if you use d or e.
* Examples for conditions:
* "2=c4" - 2nd parameter of message must be sting "c4".
* "3>10" - 3rd parameter must be greater then 10.
* "3!4" - 3rd must be different from 4.
* "2&Buy" - 2nd parameter of message must contain "Buy" substring.
* "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
native register_event(const event[],const function[],const flags[],const cond[]="", ... ); 
__________________
simanovich is offline
Reply


Thread Tools
Display Modes

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 20:37.


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